我有一个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);
%>
我想在用户登录后的第一页中使用用户名作为字符串。
如果你只打印用户名,你需要确保它有白名单的字符,例如:字母、数字。最好的方法是使用regex来过滤它。[a-zA-Z0-9]
如果你想用HTML元素来格式化用户名 (例如. <a href=userId>Username</a>
),你需要在一个消毒库中对你的元素进行消毒,如 OWASP Java消毒剂