这个jsp页面中的action=j_security_check是怎么回事啊??代码在里面

qhdwsh 2003-12-21 11:28:51
这是登陆的部分,整个系统用jboss作服务器
<html>
<head>
<title>CyberTester Login</title>
<link rel="stylesheet" href="cybertester.css" type="text/css" />
<script type="text/javascript" >
<!--
function submitform() {
var theform = document.getElementById("loginform");
theform.j_username.value = document.getElementById("loginEmail").value;
theform.j_password.value = document.getElementById("loginPassword").value;
theform.submit();
}
// -->
</script>
</head>
<body style="text-align:center;">

<div style="text-align:left;"><img src="images/logo.png" alt="CyberTester logo" /></div>

<h1>Login to CyberTester</h1>

<div id="loginBox" style="text-align:center;width:350px;border:1px solid #000055;">
<table width="100%" border="0" >
<tr>
<td rowspan="2"><img src="images/key_big.gif" alt="Key" /></td>
<td>User Email : </td>
<td><input type="text" id="loginEmail" name="loginEmail" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input type="password" id="loginPassword" name="loginPassword" /></td>
</tr>
<tr>
<td> </td>
<td><input type="button" value="Login" onclick="submitform()" /></td>
<td> </td>
</tr>
</table>
</div>

<form name="loginform" id="loginform" method="POST" action="j_security_check" >
<input type="hidden" name="j_username" value="" />
<input type="hidden" name="j_password" value="" />
</form>

</body>
</html>

...全文
227 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
希偌 2003-12-21
  • 打赏
  • 举报
回复
楼上的好象不对吧,这个是配合web.xml里对于该web appliation设置的constraint为form的验证方法的容器自动验证username和password的方法
注意:
j_username
j_password
j_security_check
这三个名字是定的,不能改变,例子:


1。在<web-app>和</web-app>之间加入

<security-constraint>

<web-resource-collection>

<web-resource-name>Entire Application</web-resource-name>

<url-pattern>/*</url-pattern>

</web-resource-collection>

<auth-constraint>

<!-- NOTE: This role is not present in the default users file -->

<role-name>user</role-name>

</auth-constraint>

</security-constraint>



<!-- Define the Login Configuration for this Application -->

<login-config>

<auth-method>FORM</auth-method>

<realm-name>TEST ACCESS CONTROL</realm-name>

</login-config>



2。然后在$TOMCAT_HOME/conf/tomcat-users.xml中加入

<user name="user" password="password" roles="user"/>

roles的名字和web.xml中的相对应
kissdavid 2003-12-21
  • 打赏
  • 举报
回复
在form的action中默认应该是XXX.do还执行一个action
可以在struts-config中找到对应的action!
filippo1980 2003-12-21
  • 打赏
  • 举报
回复
form提交后直接转向j_security_check.do
qhdwsh 2003-12-21
  • 打赏
  • 举报
回复
beyond_xiruo(CSDN腐败团团长) 说的对,
我知道了,看来你是高手啊,
谢谢大家。

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧