2011-08-26 2 views
1

메신저 매핑을 구성하고 난SpringMVC 프로젝트를 구성하려고 스프링 MVC와 톰캣에

WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/test/home.jsp] in DispatcherServlet with name 'appServlet' 

내가 여기 JSP 페이지를 컴파일 에러를하는 방법 :/테스트/SRC/메인/웹 애플리케이션/WEB-INF/ /test/src/main/webapp/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" 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_2_5.xsd"> 
    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value> 
      /WEB-INF/spring/root-context.xml 
     </param-value> 
    </context-param> 
    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
    <servlet> 
     <servlet-name>appServlet</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> 
     </init-param> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>appServlet</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 
    <filter> 
     <filter-name>charsetFilter</filter-name> 
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
     <init-param> 
      <param-name>encoding</param-name> 
      <param-value>UTF-8</param-value> 
     </init-param> 
     <init-param> 
      <param-name>forceEncoding</param-name> 
      <param-value>true</param-value> 
     </init-param> 
    </filter> 
    <filter-mapping> 
     <filter-name>charsetFilter</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 
</web-app> 

/테스트/SRC/메인/웹 애플리케이션/WEB-INF :이 내 코드입니다

보기/home.jsp /spring/appServlet/servlet-context.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> 
    <annotation-driven /> 
    <resources mapping="/resources/**" location="/resources/" /> 
    <beans:bean 
     name="test" 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <beans:property name="prefix" value="/WEB-INF/views/" /> 
     <beans:property name="suffix" value=".jsp" /> 
    </beans:bean> 
    <beans:import resource="controllers.xml" /> 
</beans:beans> 

답변

1

직접 JSP 확장자를 사용하는 확장자없이 예를 들어 HTML로 컨트롤러 맵 파일에서 다음

<display-name>appServlet</display-name> 
    <servlet> 
    <servlet-name>appServlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>appServlet</servlet-name> 
    <url-pattern>*.html</url-pattern> 
    </servlet-mapping> 

과 그것을 매핑되지 않는 : 가능한 한 빨리이 예에서는

@RequestMapping(value="/home.html", method=RequestMethod.GET) 
    public ModelAndView indexView(){ 
     ModelAndView mv = new ModelAndView("test/home"); 
     return mv; 
    } 

사용자가 /home.html Dispatcher 서블릿을 클릭하면이를 해결하고 /test/home.jsp를 검색합니다.

희망이 있습니다.

관련 문제