- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个在 apache tomcat 中运行的网络应用程序,我使用“j_security_check”来保护这个应用程序。我的代码如下,
登录.jsp
<div id="loginForm">
<form id="loginfrm" method="post" action="j_security_check">
<table>
<tr>
<td>User Name</td>
<td><input type="text" id="name" name="j_username" size="20" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="phone" name="j_password" size="20" /></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="Login" id="submitButton"></td>
</tr>
</table>
</form>
</div>
web.xml
<web-app ...>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/success.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
错误页面,
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Login ERROR!</h1>
</body>
</html>
成功页面
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Login Success</h1>
</body>
</html>
在这里,当我输入错误的用户名和密码时,错误页面会成功显示,但是当我输入正确的密码和用户名时,它会显示,
HTTP Status 400 - Invalid direct reference to form login page
type Status report
message Invalid direct reference to form login page
description The request sent by the client was syntactically incorrect (Invalid direct reference to form login page).
Apache Tomcat/7.0.22
谁能告诉我哪里错了?
最佳答案
行:
<form-login-page>/success.jsp</form-login-page>
在 web.xml
中实际上应该是:
<form-login-page>/login.jsp</form-login-page>
这告诉 tomcat 无论何时您到达 protected 页面,登录表单都位于 login.jsp
中。缺少的是实际需要身份验证才能看到的 protected 页面的定义:
<security-constraint>
<web-resource-collection>
<web-resource-name>
Entire Application
</web-resource-name>
<url-pattern>/success.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name> 'the name of the group with access' </role-name>
</auth-constraint>
</security-constraint>
以及 realm
的定义,它是您的用户名/密码对 (tomcat realm) 的存储库。
有了这些更改,当您点击 http://localhost:8080/succes.jsp
时,您应该被重定向到登录页面,并且在一组有效的凭据被发送到 /success.jsp
和一组错误的凭据到 /error.jsp
。
关于jakarta-ee - 保护 tomcat 中的 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9509847/
我想了解为什么一些 Jakarta EE 规范是空的。 例如 Jakarta Annotations规范由免责声明和快速描述(3 行)组成,但是有 Javadoc . 当 JCP 负责 J2EE 规范
我正在研究 OpenNTF 项目“XPages Jakarta EE Support”。 我正在尝试为 Person 对象上的 CRUD 操作设置 REST API。我设法创建 GET 和 POST
我正在研究 OpenNTF 项目“XPages Jakarta EE Support”。 我正在尝试为 Person 对象上的 CRUD 操作设置 REST API。我设法创建 GET 和 POST
我正在采用 Jakarta EE 9 并使用 EJB 和 WEB 模块开发一个 EE 应用程序。 EJB 已经完成并部署在 Glassfish 6(Jakarta EE 9 的 RI 实现)上。现在,
OpenLiberty(v20.0.0.2-beta 或其他版本)中是否有办法将 jakarta ee 9(通过 webProfile-9.0 或 jakartaee-9.0 或任何仅 jakarta
在使用Spring Boot 3.0.7并试图保持更新时,我遇到了这个错误,不知道它是什么意思。。加载的依赖项是Spring Security 6.0.9,问题存在于使用Java 17或19的情况下(
有没有办法在 JPA 实体监听器中检查当前事务是否已提交,如下所示? @ApplicationScoped public class EntityListener { @Inject
以下代码使用 javamail api 通过 gmail smtp 服务器发送邮件和附件。 public void doSendGmail(){ from = txtFrom.getT
大家好我有一个应用程序(spring+hibernate)需要同时发送数千封电子邮件我被告知这里最好的解决方案是有一个邮件服务器我不知道从哪里开始,或者是否有更好的框架或服务所以请大家给我一些信息,从
我正在尝试从 Java 邮件的文件夹中删除/删除消息(在我将其复制到另一个文件夹之后),这是我的代码: Flags deleted = new Flags("DELETED"); folder.se
某些页面可以接收称为“P1”的特定请求参数: page.do?P1=value1 现在,一个scriptlet正在测试request参数的存在,如果P1为“value1”,则会在页面上呈现一些信息。
我有一段非常类似于此http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailFetching的代码 我的
我在NetBeans中创建了一个Java Web应用程序项目,并在其中创建了一个启动bean: package malibu.util; import javax.annotation.PostCon
我有两个不同的项目:A 和 B。 B 包含一个拦截器,我想在项目 A 以及将来的项目 C 和 D 中使用它。 我在两个项目中都使用 jboss-javaee-6.0 版本 3.0.3.Final(这意
我一直在阅读 “Java 事务” ,我一直困惑它是什么?什么是有用的? 最佳答案 你可以谷歌搜索并找到这样的页面:http://www.java-tips.org/java-ee-tips/enter
这个问题在这里已经有了答案: What exactly is Java EE? (5 个回答) Difference between an application server and a servl
Web 应用程序的用户界面通常包含用于执行 CRUD 操作的各种按钮。在执行以下操作时,按钮标签的建议命名约定是什么? 用户创建(添加用户...或添加用户或添加用户) 事件创建(添加事件...或添加事
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我对java网页环境很陌生。最近尝试用Java开发一个电子商务平台。 因此,我使用 j_security_check 基于表单作为我的身份验证工具。身份验证完成后,成功重定向到所需页面。 但是,由于我
什么时候 我通过无状态服务从数据库中获取实体, 然后在另一个 bean 和 中修改它 然后想通过无状态服务将其保存到数据库中, 我注意到实体已分离。我认为因为无状态服务的持久化上下文,实体从被夺取到存
我是一名优秀的程序员,十分优秀!