ExtJs 用Ajax调用后台方法不管用,为何? 10
js源码:<linkrel="stylesheet"type="text/css"href="<%=path%>/js/Ext/resources/css/ext-all...
js源码:
<link rel="stylesheet" type="text/css"
href="<%=path%>/js/Ext/resources/css/ext-all.css" />
<script type="text/javascript"
src="<%=path%>/js/Ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/js/Ext/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
Ext.get("aaa").on("click",function(){
Ext.Ajax.request({
url:'myCompany.htm?action=seeOnlineCsUser',
params:{'ATTACHEDID':100006157},
success:function(req){
Ext.Msg.alert("ok"+req.responseText);
},
failure:function(){
Ext.Msg.alert(req.responseText+"failure");
}
});
});
});
</script>
java源码:
public ModelAndView seeOnLineCsUser(HttpServletRequest req,
HttpServletResponse res) {
try {
getPage(req);
} catch (Exception e) {
e.printStackTrace();
}
return new ModelAndView("myCompany/myCompanyOnLineCsUser");
}
private void getPage(HttpServletRequest req) throws CompanyServiceException {
String attachedId_s = req.getParameter("ATTACHEDID");
String online_s = req.getParameter("ONLINE");
req.setAttribute("attachedId", attachedId_s);
String currentPageNum_s = req.getParameter("currentPageNum");
String onePageMaxNum_s = req.getParameter("onePageMaxNum");
StringBuffer sb = new StringBuffer();
sb.append("&onePageMaxNum=").append(
NullOfStringToSpace.getNullOfStringToString().execute(
onePageMaxNum_s));
sb.append("&ATTACHEDID=").append(
NullOfStringToSpace.getNullOfStringToString().execute(
attachedId_s));
sb.append("&ONLINE=").append(NullOfStringToSpace.getNullOfStringToString().execute(online_s));
req.setAttribute("parameter", sb.toString());
Integer currentPageNum = null;
Integer onePageMaxNum = null;
Integer online = null;
Integer attachedId = null;
attachedId = StringToInteger.getStringToInteger().toInteger(
attachedId_s);
online = StringToInteger.getStringToInteger().toInteger(online_s);
currentPageNum = StringToInteger.getStringToInteger().toInteger(
currentPageNum_s);
onePageMaxNum = StringToInteger.getStringToInteger().toInteger(
onePageMaxNum_s);
if(onePageMaxNum == null){
onePageMaxNum=20;
}
Pageination page = csUserCompanyBusiness.veiwCsUsersByCondition(
attachedId, currentPageNum, onePageMaxNum, online);
req.setAttribute("page", page);
int onlineNum=csUserCompanyBusiness.getOnlineCsUserNum(attachedId, 1);
req.setAttribute("ONLINE", onlineNum);
int unOnlineNum=csUserCompanyBusiness.getOnlineCsUserNum(attachedId, 0);
req.setAttribute("UNONLINE", unOnlineNum);
int all=csUserCompanyBusiness.getOnlineCsUserNum(attachedId, null);
req.setAttribute("all",all); } 展开
<link rel="stylesheet" type="text/css"
href="<%=path%>/js/Ext/resources/css/ext-all.css" />
<script type="text/javascript"
src="<%=path%>/js/Ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/js/Ext/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
Ext.get("aaa").on("click",function(){
Ext.Ajax.request({
url:'myCompany.htm?action=seeOnlineCsUser',
params:{'ATTACHEDID':100006157},
success:function(req){
Ext.Msg.alert("ok"+req.responseText);
},
failure:function(){
Ext.Msg.alert(req.responseText+"failure");
}
});
});
});
</script>
java源码:
public ModelAndView seeOnLineCsUser(HttpServletRequest req,
HttpServletResponse res) {
try {
getPage(req);
} catch (Exception e) {
e.printStackTrace();
}
return new ModelAndView("myCompany/myCompanyOnLineCsUser");
}
private void getPage(HttpServletRequest req) throws CompanyServiceException {
String attachedId_s = req.getParameter("ATTACHEDID");
String online_s = req.getParameter("ONLINE");
req.setAttribute("attachedId", attachedId_s);
String currentPageNum_s = req.getParameter("currentPageNum");
String onePageMaxNum_s = req.getParameter("onePageMaxNum");
StringBuffer sb = new StringBuffer();
sb.append("&onePageMaxNum=").append(
NullOfStringToSpace.getNullOfStringToString().execute(
onePageMaxNum_s));
sb.append("&ATTACHEDID=").append(
NullOfStringToSpace.getNullOfStringToString().execute(
attachedId_s));
sb.append("&ONLINE=").append(NullOfStringToSpace.getNullOfStringToString().execute(online_s));
req.setAttribute("parameter", sb.toString());
Integer currentPageNum = null;
Integer onePageMaxNum = null;
Integer online = null;
Integer attachedId = null;
attachedId = StringToInteger.getStringToInteger().toInteger(
attachedId_s);
online = StringToInteger.getStringToInteger().toInteger(online_s);
currentPageNum = StringToInteger.getStringToInteger().toInteger(
currentPageNum_s);
onePageMaxNum = StringToInteger.getStringToInteger().toInteger(
onePageMaxNum_s);
if(onePageMaxNum == null){
onePageMaxNum=20;
}
Pageination page = csUserCompanyBusiness.veiwCsUsersByCondition(
attachedId, currentPageNum, onePageMaxNum, online);
req.setAttribute("page", page);
int onlineNum=csUserCompanyBusiness.getOnlineCsUserNum(attachedId, 1);
req.setAttribute("ONLINE", onlineNum);
int unOnlineNum=csUserCompanyBusiness.getOnlineCsUserNum(attachedId, 0);
req.setAttribute("UNONLINE", unOnlineNum);
int all=csUserCompanyBusiness.getOnlineCsUserNum(attachedId, null);
req.setAttribute("all",all); } 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询