可以在actionform 中request.getParameter("按钮名称") ==按钮value 来判断哪个按钮
解决方案 »
- 内存溢出
- 有没有JAVA EE中文API帮助文档?
- spring配置jdbc事务管理插入数据失败
- spring security配置问题
- linux下同时启动两个tomcat的问题,紧急求助!!!!!!在线等待。。。
- hibernate中如何执行类似select count(*) from a的查询,怎么取返回的值?请各位大侠帮帮忙!
- JSP 出现错误提示 org.apache.jasper.JasperException
- ActionContext.getContext().getSession().get()空指针问题
- Can't start a cloned connection while in manual transaction mode?是什么错误
- 请问rose中如何批量生成java代码?
- 一道面试题
- 新手请教:axis的作用是什么?和webservice、soap什么关系?
在Action 里用 request.getParameter("参数");接受判断 再做业务处理
if(request.getParameter("submit").equals("登录"))
return mapping.findForward("success");
else
return mapping.findForward("register");
你不是把这三个按钮都连接到一个action中吗?
加入设置一个变量 pd。
在action中判断 pd这个变量的值(自己设计 数据吧 所过是 什么就执行那个方法!)
JSP:
<input type=button onclick="regidtuser" value="注册">
<input type=button onclick="loginuser" value="登陆">
<input type=button onclick="anonymitylogin" value="匿名登陆">
<script language=JavaScript>
function regidtuser(){
form.action="***.do/?type=1";
form.submit();
}
function loginuser(){
form.action="***.do/?type=2";
form.submit();
}
function anonymitylogin(){
form.action="***.do/?type=3";
form.submit();
}
</script>ACTION:
String type=request.getparameter("type");
然后根据这个type判断是做哪种操作,在struts-config.xml这个ACTION设置多个不同的forward,程序里用mapping返回到不同的forward里就可以了。这样一个action一个actionform就可以干多件事了。
不过建议注册和登陆的ACTION还是分开的好
具体的使用你可以在网上查阅相关的资料,关于DiapathAction的使用网上很多的