Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HTTP状态404-/LoginAuth_Java_Spring_Jsp_Annotations - Fatal编程技术网

Java HTTP状态404-/LoginAuth

Java HTTP状态404-/LoginAuth,java,spring,jsp,annotations,Java,Spring,Jsp,Annotations,我正在使用spring控件注释。 但是当运行我的应用程序时,收到HTTP状态404-/LoginAuth错误 我的档案是 web.xml 请帮助我。您的设置有一些问题 首先,DispatcherServlet将创建web应用程序上下文,如DispatcherServlet.xml所定义。您无需在ContextLoaderListener的contextConfigLocation中指定此项 由于看起来您没有根应用程序上下文(通常由ContextLoaderListener加载),因此您可以从we

我正在使用spring控件注释。 但是当运行我的应用程序时,收到HTTP状态404-/LoginAuth错误

我的档案是 web.xml


请帮助我。

您的设置有一些问题

首先,DispatcherServlet将创建web应用程序上下文,如
DispatcherServlet.xml
所定义。您无需在
ContextLoaderListener
contextConfigLocation
中指定此项

由于看起来您没有根应用程序上下文(通常由
ContextLoaderListener
加载),因此您可以从
web.xml
中删除以下内容:

 <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
     </listener-class>
 </listener>
xmlns:mvc="http://www.springframework.org/schema/mvc"
架构位置为:

http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

试一试,看看你的进展如何。

这不是因为你将dispatcher servlet映射到了*.do和/LoginAuth与此url模式不匹配吗?谢谢,将根据你的情况进行更改,但现在得到的是“HTTP状态500-”错误OK,这比404要好,因为请求越来越远。您能检查应用程序日志并找到堆栈跟踪吗?如果您使用的是Tomcat,请检查
catalina.out
localhost.log
我通过将public model和view loginAuth(Request-req)替换为public model和view loginAuth(HttpServletRequest-req)解决了这个问题。再次感谢您的帮助:)
 package com.controller;
import org.apache.catalina.connector.Request;
 import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class LoginController {
@RequestMapping(value="/LoginAuth",method=RequestMethod.GET)
public ModelAndView loginAuth(Request req){
    String uname=req.getParameter("uname");
    String pass=req.getParameter("pass");
    ModelAndView mav=new ModelAndView();
    if(uname.equals("Alk") && pass.equals("Alk1234")){
        mav.setViewName("success");
    }else{
        mav.setViewName("error");
    }
    return mav;
}

 }
 <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
     </listener-class>
 </listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>
xmlns:mvc="http://www.springframework.org/schema/mvc"
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd