简体   繁体   English

org.springframework.web.servlet.DispatcherServlet noHandlerFound 404错误响应

[英]org.springframework.web.servlet.DispatcherServlet noHandlerFound 404 error response

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <display-name>Archetype Created Web Application</display-name>
    <servlet>
        <servlet-name>sample</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>sample</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

the index file where I added a form and action "output" 我添加表单和操作“输出”的索引文件

<html>
<body>  <form action="output">
        <input type="text" name="t1"></br> <input type="text" name="t2"></br>
        <input type="submit">
    </form>
</body>
</html>

The servlet is configured as below servlet配置如下

<?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:p="http://www.springframework.org/schema/p"
  xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:tx="http://www.springframework.org/schema/tx"
  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-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.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-3.0.xsd">

<context:annotation-config></context:annotation-config>
<context:component-scan base-package="com.guni.Controllers"></context:component-scan>
</beans>

sampleController.java sampleController.java

package com.guni;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class sampleController { 
    @RequestMapping(value="/output", method = RequestMethod.GET)
    public String karna()
    {
        return "sampleOutput.jsp";
    }
}

I am trying to execute a form GET with submit button. 我正在尝试使用提交按钮执行表单GET。 the Submit button does not respond any thing. 提交按钮不响应任何事情。 The web page gives me 404 error. 该网页给出了404错误。 Any body has any idea.I am using eclipse 2019 and tomcat9. 任何身体都有任何想法。我正在使用eclipse 2019和tomcat9。 i am trying to create a web application in maven using spring 4.0 我正在尝试使用Spring 4.0在maven中创建一个Web应用程序

When i run the project it gives me the bellow error org.springframework.web.servlet.DispatcherServlet noHandlerFound No mapping for GET /demoMVC/output 当我运行项目时它给我下面的错误org.springframework.web.servlet.DispatcherServlet noHandlerFound没有GET / demoMVC /输出的映射

Your controller method is registered to accept GET requests on /output , while you're performing a GET request on /demoMVC/output . 你的控制器方法被注册为接受GET请求/output ,当你执行一个GET请求/demoMVC/output Either modify your @RequestMapping value to /demoMVC/output , or change the URL you're calling in your browser. @RequestMapping值修改为/demoMVC/output ,或更改您在浏览器中调用的URL。

Furthermore, in many cases an InternalResourceViewResolver is configured to return the name of the JSP file without the .jsp suffix. 此外,在许多情况下, InternalResourceViewResolver配置为返回没有.jsp后缀的JSP文件的名称。 Assuming you've created a file named sampleOutput.jsp , adjust your karna() method to return "sampleOutput" instead of "sampleOutput.jsp" . 假设您已创建名为sampleOutput.jsp的文件,请调整karna()方法以返回"sampleOutput"而不是"sampleOutput.jsp" If this does not work, would you be able to you post your InternalResourceViewResolver configuration? 如果这不起作用,您能否发布InternalResourceViewResolver配置?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.springframework.web.servlet.DispatcherServlet noHandlerFound - org.springframework.web.servlet.DispatcherServlet noHandlerFound org.springframework.web.servlet.DispatcherServlet noHandlerFound:Spring MVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound : Spring MVC org.springframework.web.servlet.DispatcherServlet noHandlerFound用于基本的Spring示例 - org.springframework.web.servlet.DispatcherServlet noHandlerFound for basic spring example 如何解决Spring框架项目错误org.springframework.web.servlet.DispatcherServlet noHandlerFound? - How to resolve Spring framework project error org.springframework.web.servlet.DispatcherServlet noHandlerFound? 错误[org.springframework.web.servlet.DispatcherServlet] - ERROR [org.springframework.web.servlet.DispatcherServlet] org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI in DispatcherServlet with name - org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI in DispatcherServlet with name 获取此 org.springframework.web.servlet.DispatcherServlet noHandlerFound 错误和警告:在 Spring MVC 中找不到 HTTP 请求 URI 的映射 - Getting this org.springframework.web.servlet.DispatcherServlet noHandlerFound error and WARNING: No mapping found for HTTP request URI in Spring MVC 实例化servlet类org.springframework.web.servlet.DispatcherServlet时出错 - Error instantiating servlet class org.springframework.web.servlet.Dispatcherservlet org.springframework.web.servlet.DispatcherServlet noHandlerFound 警告:GET /HelloWorld/helloweb 没有映射 - org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping for GET /HelloWorld/helloweb org.springframework.web.servlet.DispatcherServlet noHandlerFound 警告:GET /springMVCDemo/createAccount.html 没有映射 - org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping for GET /springMVCDemo/createAccount.html
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM