struts2 动态调用action中方法
来源:互联网 发布:炉石传说mac记牌器 编辑:程序博客网 时间:2024/05/15 14:02
1. jsp页面代码
submit 提交的action 写成"action_login" ,和sturts2文件中配置的name=“action_*” 匹配, " * "通配符在将此作为了sturts2文件里的{1} 的参数值,即login 。
<s:form action="admin_login">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="300" height="200" style="margin:auto;">
<tr>
<td width="100"><s:text name="login_label_loginname"/>:</td>
<td><s:textfield name="loginName" size="26"/></td>
</tr>
<tr>
<td width="100"><s:text name="login_label_password"/>:</td>
<td><s:password name="loginPwd" size="26"/></td>
</tr>
<tr>
<td width="100"><s:text name="login_label_rand"/>:</td>
<td><s:textfield name="rand" size="26"/>
<img name="pic" id="pic" src="<%=basepath%>/common/rand.jsp" height="16" border="1" onClick="changeRand();" style="cursor:pointer;" alt="点击重新获取验证码"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<s:submit key="login_submit"/>
</td>
</tr>
</table>
</s:form>
2. sturts2文件中的配置
<action name="admin_*" class="adminAction" method="{1}">
<result>/admin/{1}.jsp</result>
<result name="input">/admin/{1}.jsp</result>
<result name="index">/admin/index.jsp</result>
<result name="login">/admin/login.jsp</result>
<result name="toBrowseAdmin" type="redirect-action">
<param name="actionName">admin_browseAdmin</param>
<param name="namespace">/admin</param>
<param name="actionMsg">${actionMsg}</param>
</result>
<interceptor-ref name="loginedCheck"/>
<interceptor-ref name="defaultStack"/>
</action>
3. action 文件中的方法
//获取login.jsp界面 中输入的账户和密码
private Admin model = new Admin();
public Admin getModel()
{
return model;
}
//通过sturts2文件中配置的路径调用action中的登录方法
public String login()
{
String strReturn = "login";
if (1!=1 && !rand.equalsIgnoreCase((String) ServletActionContext.getRequest().getSession().getAttribute("rand")) )
{
addActionError(getText("login_rand_error"));
}
else
{
System.out.println("1233");
Admin tAdmin = ((AdminService) service).getAdminByNameAndPwd(model.getLoginName(), model.getLoginPwd());
if ( tAdmin != null )
{
ServletActionContext.getRequest().getSession().setAttribute("admin", tAdmin);
strReturn = "index"; // ��½У��ɹ�����ת��������ҳ
}
else
{
addActionError(getText("login_fail"));
}
}
return strReturn;
}
- struts2 中action的动态方法调用
- struts2 动态调用action中方法
- Struts2中Action的动态调用方法
- Struts2中Action的动态调用方法
- Struts2中Action的动态方法调用
- struts2 action动态方法调用
- struts2中动态方法调用和使用通配符定义Action
- Struts2框架5.Action中动态方法调用
- struts2动态方法调用 ActionName!methodName.action
- struts2动态方法调用 ActionName!methodName.action
- 复习Struts2之Action动态方法调用
- Struts2-02Action动态方法调用
- Struts2动态方法调用,找不到Action
- Struts2——Action动态方法调用
- Struts2-动态调用action中的方法
- struts2 action DMI动态方法调用
- Struts2中Action动态访问调用
- Struts2的动态调用Action方法和默认Action
- mysql修改表、字段、库的字符集
- 获取发布后项目在服务器的绝对路径
- Linux开启mysql远程连接的设置步骤
- 网站架构网站
- Linux 6.3下安装Oracle Enterprise Cloud Control 12c
- struts2 动态调用action中方法
- Android中设置输入法为数字输入
- android浏览器书签插入去重算法
- KVO、KVC、NSNotificationCenter实例
- 商派
- 《JavaScript高级程序设计 第三版》学习笔记 (十二)Ajax详解
- LaTex 配置[ TeXnicCenter, Adobe Reader]
- 在自己弄的xml模仿的
- Win32下利用_beginthread函数创建一个线程