我在 MyController 中有一个代码
 @RequestMapping("/hello.jsp")
    public void handleRequest() {
        System.out.println("hello.jsp");
        logger.info("Returning hello view");
    }
    @RequestMapping("/hello2")
    public ModelAndView hello2() {
        System.out.println("123");
        String message = "Hello World, Spring 3.0!";
        return new ModelAndView("hello2", "message", message);
    }
在 dispatcher-servlet.xml 我有:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">       
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>
最后我有:
~8080/hello2.htm - OK
~8080/hello.htm  - NOT OK, aloso I tried: hello.jsp, hello; moved hello.jsp to /WEB-INF/jsp/ and to/WEB-INF/ - no effect 
1.hello2() is working well, and redirecting to the hello2.jsp
2.hello() is NOT working, and NOT redirecting
在将“viewResolver”放入 dispatcher-servlet.xml 之前,我有相反的行为 - hello() 正在工作 hello2() 不是。[但后来我的所有 jps 都在 WEB-INF 文件夹中]
是什么原因?
我的 web.xml 包括:
  <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>