警告: No mapping found for HTTP request with URI [/springmvc4/test1/helloworld] in DispatcherServlet with name 'springmvc'
運行後一直報錯。
我貼下代碼 各位幫我看下
web配置:
<?xml version="1.0" encoding="UTF-8"?>
springMVC1
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
spring-servlet.xml配置
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath*:config/spring-servlet.xml
1
springmvc
/
<?xml version="1.0" encoding="UTF-8"?>
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
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.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<bean name="/test1/helloworld" class="com.web.controller.HelloWorldController" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
com.web.controller下的類:
package com.web.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class HelloWorldController implements Controller{
public ModelAndView handleRequest(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
System.out.println("aasdadasd");
return new ModelAndView("/welcome");
}
}
你 /springmvc4/test1/helloworld
這個對應的url 找不到你的controller 中的方法 ,看看是否掃描到相應的controller