方法二指定method
<struts>
<package name="lee" extends="struts-default">
<action name="Login" class="lee.LoginRegistAction">
<result name="input">/login.jsp</result>
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
</action>
<action name="Regist" class="lee.LoginRegistAction" method="regist">
<result name="input">/login.jsp</result>
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
</action>
</package>
</struts>
<%@ page language="java" contentType="text/html; charset=GBK"%>
<script>
function regist()
{
targetForm = document.forms[0];
targetForm.action = "Regist.action";
targetForm.submit();
}
</script>
<html>
<head>
<title>登陆页面</title>
</head>
<body>
<table width="300" align="center">
<form action="Login.action" method="post">
<tr>
<td>用户名:</td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="text" name="password"/></td>
</tr>
<tr>
<td><input type="submit" value="登陆"/></td>
<td><input type="button" value="注册" onClick="regist();"/></td>
</tr>
</form>
<table>
</body>
</html>
本文介绍了一个使用Struts框架实现的简单登录和注册功能的配置示例。通过具体的XML配置文件和HTML表单代码,展示了如何定义登录与注册的动作及结果页面。
976

被折叠的 条评论
为什么被折叠?



