JAX-RS '(저지) MVC 패턴을 사용하려고합니다. 시도라는 오류에 http://localhost:8080/myproject/foos/test 결과에 도달 : 같은 오류JAX-RS 서비스를 MVC 템플릿에 연결할 수 없습니다.
java.io.IOException: The template name, /view, could not be resolved to a fully qualified template name
http://localhost:8080/myproject/foos 결과를.
무엇이 누락 되었습니까?
리소스 :
package resources;
import com.sun.jersey.api.view.Viewable;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("foos")
public class FooResource {
@GET
@Produces(MediaType.TEXT_HTML)
public Viewable get() {
return new Viewable("/index", this);
}
@GET
@Path("{id}")
@Produces(MediaType.TEXT_HTML)
public Viewable get(@PathParam("id") String id) {
return new Viewable("/view", id);
}
}
조회수 :/JSP/자원/FooResource
웹 index.jsp를
-
WEB-INF .xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <filter> <filter-name>jersey</filter-name> <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class> <init-param> <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name> <param-value>/(resources|images|js|styles|(WEB-INF/jsp))/.*</param-value> </init-param> </filter> <filter-mapping> <filter-name>jersey</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>ServletAdaptor</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <description>Set the default, base template path to the WEB-INF folder.</description> <param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name> <param-value>/WEB-INF/jsp</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ServletAdaptor</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> </web-app>