我的web.xml如下......
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
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"
id="Your_Webapp_ID" version="3.0">
<display-name>Spring MVC Application</display-name>
<servlet>
<servlet-name>MyMVCAppCustom</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyMVCAppCustom</servlet-name>
<url-pattern>*.app</url-pattern>
</servlet-mapping>
</web-app>
我得到的警告是......
WARNING [http-apr-8080-exec-10] org.springframework.web.servlet.DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI [/DynWebProj/WEB-INF/springMVCjsps/MyHello.jsp] in DispatcherServlet with name 'MyMVCAppCustom'
真奇怪的是,SPRING已进入我的控制器方法,并且已经转到我的视图解析器,很明显我的jsp文件位于此位置 /DynWebProj/WEB-INF/springMVCjsps/MyHello.jsp 但它声称那里没有处理程序!我甚至从Controller类中发布了一条system.out消息。
printHello3 {message=hello Hello Spring MVC Framework!}
在tomcat控制台中,它们也可以很好地加载....
INFO [localhost-startStop-1] org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/bingo],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String code.xander.mvc.MyHelloController.printHello3(org.springframework.ui.ModelMap)
INFO [localhost-startStop-1] org.springframework.web.servlet.FrameworkServlet.initServletBean FrameworkServlet 'MyMVCAppCustom': initialization completed in 1931 ms
我的浏览器网址是.....
http://localhost:8080/DynWebProj/bingo.app
我真的很沮丧,因为我已经在小跑上挣扎了3天。奇怪的是,它突然开始工作,现在已经停止了。让我得到的是这个问题几乎是量子行为。
如果你已经在这里阅读了,我也可以添加我的控制器类......
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class MyHelloController {
@RequestMapping(value = "/bingo", method = RequestMethod.GET)
public String printHello3(ModelMap model) {
model.addAttribute("message", "hello Hello Spring MVC Framework!");
System.out.println("printHello3 " + model);
return "MyHello";
}
}
在这里添加了我的Spring mvc servlet config xml文件.....
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="code.xander.mvc" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/springMVCjsps/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
正如您所看到的,即使Spring + Tomcat没有呈现我的页面。警告映射到我的jsp页面的位置.....所以,我只是无法理解为什么它无法呈现它。
WARNING [http-apr-8080-exec-10] org.springframework.web.servlet.DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI [/DynWebProj/WEB-INF/springMVCjsps/MyHello.jsp] in DispatcherServlet with name 'MyMVCAppCustom'
DynWebProj是我的应用程序的Web根目录。我用过eclipse。当我&#34; runas&#34;我得到相同的消息。当我创建一个WAR文件并部署到我的tomcat webapps目录时。