-1
Java EEベースのプロジェクト用のシンプルなJAX-RSリソースクラスを作成しました。私はサーバーから応答を返そうとしていますが、私のURLにアクセスするとエラーが返ってきます。これは私が書いたクラスです:JAX-RSリソースにはどのようにアクセスできますか?
@Path("/rest")
public class RestResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String create(String name)
{
return "print my string";
}
}
私が間違っていることを理解できません。 web.xmlに新しいサーブレットを定義する必要はありますか?私の現在のものに何か問題はありますか?
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
metadata-complete="false">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<display-name>crud-app</display-name>
<!-- Activate the JSF 2.0 servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Tell the context which URLs to send through JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- This is an optional parameter, but it makes troubleshooting errors
much easier -->
<!-- You are advised to remove this context parameter before a production
deployment -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>person.jsf</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/ui/error/error.jsf</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/ui/error/viewExpired.jsf</location>
</error-page>
</web-app>
これは何に配備していますか?それはエンタープライズコンテナかTomcatのようなサーブレットコンテナですか? –
私はそれをwildflyサーバーに展開しています。私はresteasyを使って自分の問題を解決しました – ffs