Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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 Can';t使用我的login.jsp页面登录_Java_Spring_Jsp_Spring Mvc_Spring Security - Fatal编程技术网

Java Can';t使用我的login.jsp页面登录

Java Can';t使用我的login.jsp页面登录,java,spring,jsp,spring-mvc,spring-security,Java,Spring,Jsp,Spring Mvc,Spring Security,我使用的是SpringMVC4.1和SpringSecurity4.0。我想使用我自己的登录页面,但Spring Security总是给我拒绝访问的页面。如果我使用默认登录页面,一切都很好。这是我的security.xml 这是login.jsp <html> <head> <title>Log in</title> </head> <body> <div class="row"> <div cla

我使用的是SpringMVC4.1和SpringSecurity4.0。我想使用我自己的登录页面,但Spring Security总是给我拒绝访问的页面。如果我使用默认登录页面,一切都很好。这是我的security.xml


这是login.jsp

<html>
<head>
<title>Log in</title>
</head>
<body>
<div class="row">
<div class="container">
    <h1>Forque Sign In</h1>
    <c:url value="/login" var="loginUrl"/>
    <form action="${loginUrl}" method="post">
        <c:if test="${param.error != null}">
            <div class="alert alert-error">
                Failed to login.
                <c:if test="${SPRING_SECURITY_LAST_EXCEPTION != null}">
                    Reason: <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" />
                </c:if>
            </div>
        </c:if>
        <c:if test="${param.logout != null}">
            <div class="alert alert-success">
                You have been logged out.
            </div>
        </c:if>
        <label for="username">Username</label>
        <input type="text" id="username" name="username"/>
        <label for="password">Password</label>
        <input type="password" id="password" name="password"/>
        <div class="form-actions">
            <input class="btn" type="submit" value="Login"/>
        </div>
    </form>
    </div>
    </div>
    </body>
  </html>

登录
Forque登录
登录失败。
原因:
您已注销。
用户名
密码

尝试删除登录处理url

<form-login login-page="/login" username-parameter="username" password-parameter="password" authentication-failure-url="/Access_Denied"/>


spring甚至不允许您查看/login页面,或者在/login页面上提交完整的登录详细信息后访问被拒绝?spring在提交后重定向到访问被拒绝页面确定提交表单时日志/控制台输出会说什么?查看日志/控制台输出会很有用。顺便说一句,我看不出用户成功登录后应该指向哪个页面,即在我的应用程序中,用户被发送到/menu,代码是:默认目标url=“/menu”,添加到登录标记表单spm org.springframework.web.servlet.PageNotFound noHandlerFound警告:未找到URI为HTTP请求的映射[/errors/403]在名为“dispatcher”的DispatcherServlet中,因为我还没有添加错误页面,但为什么spring security重定向到403页面?我也看不到在哪里执行身份验证检查,在我的login.jsp中,我(在HTML表单标记中)有以下内容:不幸的是,它不起作用。当我使用自定义登录页面时,一切正常。你能解释一下我应该做什么来建立自己的登录页面吗?你有自己的登录请求映射吗??与j_spring_security_checkYes不同,它看起来像:@RequestMapping(value=“/login”,method=RequestMethod.GET)public ModelAndView showloginfo(){return new ModelAndView(“login”);}在spring 4.0中+需要明确定义处理URL。它不再是
j\u spring\u security\u check
。它默认为
/login
<form-login login-page="/login" username-parameter="username" password-parameter="password" authentication-failure-url="/Access_Denied"/>