(笔记) Struts 中PassValue 的代码实现
--Struts的配置--
<struts>
<include file="struts-default.xml" />
<package name="struts2" extends="struts-default">
<action name="loginAction" type="redirectAction">
<param name="actionName">dologinAction</param>
<param name="user">${usersbean.user}</param>
<param name="password">${usersbean.password}</param>
</result>
<result name="input">Login.jsp</result>
</action>
<action name="dologinAction" >
<result name="success">Hello.jsp</result>
<result name="input">Login.jsp</result>
</action>
</package>
</struts>
---Jsp页面上---
1:Login.jsp
<form action="loginAction.action" method="post">
<table align="center">
<tr><td><strong>Smurf ID:</strong></td><td><input type="text" name="usersbean.user" value="" size="20" width="20"/></td></tr>
<tr><td><strong>Password:</strong></td><td><input type="password" name="usersbean.password" value="" size="20" width="20"/></td></tr>
<tr><td><strong>You are :</strong></td><td><input type="radio" name="type" value="1" checked/>Member</td><td><input type="radio" name="type" value="2"/>Admin</td></tr>
<tr><td><strong><input type="submit" name="signin" value="Sign In"></strong></td><td><strong><input type="reset" name="reset" value="Clear" width="60%"></strong></td></tr>
</table>
</form>
2:Hello.jsp
<body>
This is my JSP page. <br>
Smurfs ID: ${user};<br>
Smurgs PWD: ${password};
</body>
----此类方法 用于页面预览可以不通过数据库直接传值----