No mapping found for HTTP request with URI [/spring/WEB-INF/page/index.jsp] in DispatcherServlet with name 'spring'
来源:互联网 发布:mac os x 10.11百度云 编辑:程序博客网 时间:2024/04/29 04:24
今天试了下spring mvc遇到个很奇怪的事情,按照书上配置访问时总是出现如下警告:
org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/myspring/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name 'spring'
web.xml
Xml代码
- <servlet>
- <servlet-name>spring</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/springContext.xml</param-value>
- </init-param>
- </servlet>
- <servlet-mapping>
- <servlet-name>spring</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
<servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/springContext.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
springContext.xml
Xml代码
- <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value="/WEB-INF/jsp/" />
- <property name="suffix" value=".jsp" />
- </bean>
- <bean name="/hc" class="com.hj.controllers.HelloController"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <bean name="/hc" class="com.hj.controllers.HelloController"/>
HelloController.java
Java代码
- @Override
- protected ModelAndView handleRequestInternal(HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- return new ModelAndView("hello");
- }
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { return new ModelAndView("hello"); }
在项目/WEB-INF/jsp目录下防止hello.jsp文件。按照上述配置访问http://localhost:8081/myspring /hc,应该是出现hello.jsp内容才对,但是却出现了一开始提到的警告。我搜索了许多地方,结果在一老外的提供中找到了同样的问题(http: //forum.springsource.org/archive/index.php/t-71263.html),解决方法老外也说明了,只是不知 道为什么。
就是将web.xml中
Xml代码
- <servlet-mapping>
- <servlet-name>spring</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
<servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
改成
Java代码
- <servlet-mapping>
- <servlet-name>spring</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
<servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
spring MVC的困惑--url-pattern的/和/*有区别
Spring MVC 遇到的一点点问题
- No mapping found for HTTP request with URI [/spring/WEB-INF/page/index.jsp] in DispatcherServlet with name 'spring'
- No mapping found for HTTP request with URI [/Demo/WEB-INF/page/login.jsp] in DispatcherServlet with
- No mapping found for HTTP request with URI [/login.do] in DispatcherServlet with name 'spring'
- Spring : No mapping found for HTTP request with URI in DispatcherServlet with name "..."
- No mapping found for HTTP request with URI [/prjName/contro] in DispatcherServlet with name 'spring'
- No mapping found for HTTP request with URI [/cwgl/department/index] in DispatcherServlet with name
- No mapping found for HTTP request with URI [/index.html] in DispatcherServlet with name 'springmvc'
- No mapping found for HTTP request with URI [/index.do] in DispatcherServlet with name 'SpringMVC‘
- spring框架的项目报错:No mapping found for HTTP request with URI [ ] in DispatcherServlet with name 'spring'
- Spring MVC静态资源拦截(No mapping found for HTTP request with URI in DispatcherServlet with name ' ')问题
- 警告: No mapping found for HTTP request with URI [/bks_xk/WEB-INF/jsps/first.jsp] in DispatcherServlet
- spring mvc No mapping found for HTTP request with URI [] in DispatcherServlet
- No mapping found for HTTP request with URI[路径] in DispatcherServlet with name spring3
- No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
- 警告: No mapping found for HTTP request with URI [] in DispatcherServlet with name
- No mapping found for HTTP request with URI [/chart/get] in DispatcherServlet with name 'SpringMVC‘
- No mapping found for HTTP request with URI in DispatcherServlet with name 'XXX'
- No mapping found for HTTP request with URI [...] in DispatcherServlet with name '...'
- JdbcTemplate 查询
- MyEclipse10 中的两种FreeMarker插件的安装与配置
- eclipse 环境下 FreeMarker 编辑器插件
- eclipse界面定制,让eclipse看着更清爽
- Spring配置项之<context:component-scan base-package="..."/>
- No mapping found for HTTP request with URI [/spring/WEB-INF/page/index.jsp] in DispatcherServlet with name 'spring'
- request 报错The remote server returned an error: (415) Unsupported Media Type.
- easyui 获得ComboBox选中项的值 getValue
- 读取web应用中properties配置文件(这种方法可能不是最好的)
- js格式化日期
- where 和 on 的区别
- Uncaught SyntaxError: Unexpected token <
- mysql查看表结构命令
- textarea 为什么删除内容之后就不能再赋值了呢