+ -
当前位置:首页 → 问答吧 → 雪里跪求、、、、、struts2 action 方法中怎么传入request response和响应页面!

雪里跪求、、、、、struts2 action 方法中怎么传入request response和响应页面!

时间:2011-10-21

来源:互联网

//action配制
<package name="login" extends="json-default" namespace="/">
<action name="login" class="com.karel.lgy.action.LoginAction" method="login">
<result type="json"></result> 
</action>
</package>
//action里方法
public String login() {//怎么在里面配参数request response 响应前台请求??????

try{
loginService.login(uid, pwd);
this.success=true;

session.put("user", u);
}catch(Exception e){
this.message="登录失败:" + e.getMessage();
this.success=false;
}
return SUCCESS;
}
//前台请求
 function login(){
mask.show();
  fs.getForm().submit({
url:'login!login.action', 
success : function(form,action) {
document.location.href = 'index.jsp';
},
failure : function(form,action) {
mask.hide();
Ext.MessageBox.alert('登录失败', action.result.message);
return;
  }
  });
  }
也就是说前台请求时把request reponse也传给login()这个方法????

作者: liu955x   发布时间: 2011-10-21

你去action中得到servletAPI的方式,有两种,一种是iOC方式,一种是非IOC方式。你就明白了。

作者: licip   发布时间: 2011-10-21

这个我知道,非ioc是通过ActionContext 
ioc是实现...Aware接口  
我就是想知道,怎么在这个action中的login方法中加个参数,如login(HttpServletRequest request,HttpServletResponse response),我如果直接写成这样,struts2找不到这个方法,
俺是新手,请大家多多照顾、、、、

作者: liu955x   发布时间: 2011-10-21

热门下载

更多