錯誤葛亭:警告:未找到HTTP請求與URI映射在DispatcherServlet的與名稱telusuko [/ SpringTest /添加]
2017年3月3日下午7點06分58秒org.springframework.web.servlet.PageNotFound noHandlerFound 警告:沒有找到映射與URI HTTP請求中的DispatcherServlet名爲 'telusuko'
調用此
http://localhost:8085/SpringTest/index.jsp網址工作正常[/ SpringTest /添加。
不工作的404錯誤讓
AddController:
package com.springs;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class AddController {
@RequestMapping(value="/add")
public String add(){
return "display.jsp";
//System.out.println("work");
}
}
telusuko-servlet.xml中
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd ">
<ctx:annotation-config></ctx:annotation-config>
<ctx:component-scan base-package="com.springs"></ctx:component-scan>
</beans>
的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>telusuko</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>telusuko</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
的index.jsp:
<html>
<body>
<h2>Hello World!</h2>
<form action="add">
<input type="text" name="t1" />
<input type="text" name="t2" />
<input type="submit" />
</form>
</body>
</html>
沒有使用任何其他建議? – srinivas
嘗試從回車中刪除「.Jsp」,並在評論中打印我提交後的URL – OEH
我是用system.out.println代替jsp文件編寫的,甚至無法運行。 DispatcherServlet無法使用@Controller查找配置的類 – srinivas