gpt4 book ai didi

java - 警告 : No mapping found for HTTP request with URI [/SpringTest/add] in DispatcherServlet with name telusuko

转载 作者:行者123 更新时间:2023-11-30 06:51:53 25 4
gpt4 key购买 nike

获取错误:

2017 年 3 月 3 日下午 7:06:58 org.springframework.web.servlet.PageNotFound noHandlerFound警告:在名为“telusuko”的 DispatcherServlet 中未找到带有 URI [/SpringTest/add] 的 HTTP 请求的映射

从此调用

http://localhost:8085/SpringTest/index.jsp网址工作正常。

http://localhost:8085/SpringTest/add?t1=dfvd&t2=vdfvfd不工作 404 错误获取

添加 Controller :

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>

最佳答案

确保您在“src/main/java”中创建包和类,而不是在“src/main/resources”中创建包和类'

关于java - 警告 : No mapping found for HTTP request with URI [/SpringTest/add] in DispatcherServlet with name telusuko,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42591643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com