No mapping found for HTTP request with URI错误,找了一天了也没解决
刚学spring mvc,按照介绍写的代码,一直报这个错误,component-scan加了,mvc:annotation-driven加了,mvc:default-servlet-handler也加了,就是不行,还请各位前辈帮看下。
web.xml配置:
hellospring-config.xml
HelloController
web.xml配置:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>hellospring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:WEB-INF/hellospring-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>hellospring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
hellospring-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">
<context:component-scan base-package="com.hellospring.web" />
<mvc:annotation-driven />
<mvc:default-servlet-handler/>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" />
</beans>
HelloController
package com.hellospring.web.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
@Controller
public class HelloController extends AbstractController {
//define log
private static final Logger logger = Logger.getLogger(HelloController.class.getName());
@Override
@RequestMapping(value="/hello")
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
// TODO Auto-generated method stub
logger.info("hello controller start....");
ModelAndView mvc = new ModelAndView();
mvc.addObject("message", "hello spring");
mvc.setViewName("/WEB-INF/hello/welcome.jsp");
return mvc;
}
}
...全文
相关推荐
http错误代码集合
---### 特殊的HTTP错误代码#### 400系列错误- **400 Bad Request**:客户端请求存在语法错误或逻辑问题。
常见IIS错误,适合web编程者
- **404 Not Found**:请求的资源不存在。 - **404.0 Not Found**:找不到文件或目录。
spring 问题总结实用知识库分享知识分享
SpringMVC:No mapping found for HTTP request with URI [/account/*] in DispatcherServlet with在使用 SpringMVC
hht 数字错误信息
**HTTP 400 Bad Request**- **描述**:请求报文中存在语法错误。- **原因**:通常是因为客户端发送的数据格式不正确。
springmvc静态资源访问
-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot


