2
下面是一个最简单的表单提交页面,代码:
<%@ page language="java" contentType="text/html; charset=GBK"%>
<html>
<head>
<title>登录页面</title>
</head>
<body>
<!-- 提交请求参数的表单 -->
<form action="Login.action" method="post">
<table align="center">
<caption><h3>用户登录</h3></caption>
<tr>
<!-- 用户名的表单域 -->
<td>用户名:<input type="text" name="username"/></td>
</tr>
<tr>
<!-- 密码的表单域 -->
<td>密 码:<input type="text" name="password"/></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="登录"/><input
type="reset" value="重填" /></td>
</tr>
</table>
</form>
</body>
</html>
我们注意到该表单的action属性:login.action,这个action属性比较特殊,它不是一个普通的Servlet,也不是一个动态JSP页面。当表单提交给login.action时,Struts 2的FilterDispatcher将自动起作用,将用户请求转发到对应的Action。
