前台:
<form action="" method="post">
<input type="text" name="userName" />
<input type="submit" value="提交" />
</form>
jsp输出:
<%
TestActionForm tf = (TestActionForm)request.getAttribute("testActionForm");
%>
<%=tf.getUserName()%>
<%=tf.getPassword()%>
EL表达式输出:
${testActionForm.userName} //testActionForm 为 struts-config.xml 中actionForm的name值
${testActionForm.password}
后台:
ActionForm
private String userName;
private String password;
运行:
输入jack
不输入任何值
输出:
jsp输出:
姓名:jack
密码:null
姓名:
密码:null
jstl输出:
姓名:jack
密码:
姓名:
密码: