在 j_security 表单的另一侧调用用户名?
calling username on other side of j_security form?
我有这个 j 安全表格,但我一直卡在如何将用户名带到下一页
<form action="j_security_check" name="loginForm" method="post">
<h:outputLabel for="username" value="Username:" />
<input type="text" id="username" name="j_username" size="20"/>
<h:outputLabel for="password" value="Password:" />
<input type="password" id="password" name="j_password" size="20"/>
<br/>
<h:message for="user" title="User"/>
<button value="Submit" type="submit" outcome="securityvalid">Submit</button>
<button value="Reset" type="reset">Reset</button>
</form>
我想要一个像这样运行的 servlet...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
<%
out.print(username);
%>
我基本上想要用户登录后可以在第一页上用作字符串的用户名
如果你只打印用户名,你需要确保它有白名单字符,例如。字母,数字。使用正则表达式过滤它的最佳方法:[a-zA-Z0-9]
如果你想用 HTML 元素格式化用户名(例如 <a href=userId>Username</a>
),你需要在像 OWASP Java Sanitizer
这样的清理器库中清理你的元素
我有这个 j 安全表格,但我一直卡在如何将用户名带到下一页
<form action="j_security_check" name="loginForm" method="post">
<h:outputLabel for="username" value="Username:" />
<input type="text" id="username" name="j_username" size="20"/>
<h:outputLabel for="password" value="Password:" />
<input type="password" id="password" name="j_password" size="20"/>
<br/>
<h:message for="user" title="User"/>
<button value="Submit" type="submit" outcome="securityvalid">Submit</button>
<button value="Reset" type="reset">Reset</button>
</form>
我想要一个像这样运行的 servlet...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
<%
out.print(username);
%>
我基本上想要用户登录后可以在第一页上用作字符串的用户名
如果你只打印用户名,你需要确保它有白名单字符,例如。字母,数字。使用正则表达式过滤它的最佳方法:[a-zA-Z0-9]
如果你想用 HTML 元素格式化用户名(例如 <a href=userId>Username</a>
),你需要在像 OWASP Java Sanitizer