struts1重定向
已经实现了的功能:
两种工单分别请求能正常获取到页面数据,
1、请求 http://10.101.214.121:9080/eoms35/sheet/complaint/complaint.do?method=showDetailPageByGreenNo&greenNo=20200702ceshi5
返回detail.jsp
代码如下
ComplaintAction类中
public ActionForward showDetailPageByGreenNo(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
IMainService iMainService = (IMainService) ApplicationContextHolder.getInstance().getBean(
"iComplaintMainManager");
IMainService complaintHomeiMainService = (IMainService)ApplicationContextHolder.getInstance().getBean("iComplaintHomeMainManager");
String greenNo = StaticMethod.null2String(request.getParameter("greenNo"));
if (!greenNo.equals("")) {
List list = iMainService.getMainListByParentSheetId(greenNo);
List listComplaintHome = complaintHomeiMainService.getMainListByParentSheetId(greenNo);
if (list != null && list.size() > 0) {
BaseMain baseMain = (BaseMain) list.get(0);
request.setAttribute("sheetKey", baseMain.getId());
String beanName = mapping.getAttribute();
IBaseSheet baseSheet = (IBaseSheet) getBean(beanName);
baseSheet.showDetailPage(mapping, form, request, response);
return mapping.findForward("detail");
}
else if (listComplaintHome != null && listComplaintHome.size() > 0) {
//获得此工单main表id,并存在request中。
// BaseMain baseMain = (BaseMain) listComplaintHome.get(0);
// request.setAttribute("sheetKey", baseMain.getId());
// String beanName = mapping.getAttribute();
// IBaseSheet baseSheet = (IBaseSheet) getBean("ComplaintHome");
// baseSheet.showDetailPage(mapping, form, request, response);
// ActionForward forward = mapping.findForward("showDetailPageByGreenNo");
ActionForward forward = new ActionForward("complainthome.do?method=showDetailPageByGreenNo&greenNo="+greenNo);
forward.setRedirect(true);
return forward;
}
else {
BocoLog.info(this, "不存在工单号为:" + greenNo + "的工单!");
return mapping.findForward("error");
}
} else {
BocoLog.info(this, "工单号不能为空!");
return mapping.findForward("error");
}
}
struts配置文件如下 struts-config-sheet-complaint.xml
<action path="/complaint"
type="com.boco.eoms.sheet.complaint.webapp.action.ComplaintAction"
name="multiPageForm" scope="request" input="error" parameter="method"
unknown="false" validate="false" attribute="Complaint">
<forward name="detail"
path="/WEB-INF/pages/wfworksheet/complaint/detail.jsp"
redirect="false" contextRelative="true" />
</action>
2、请求地址http://10.101.214.121:9080/eoms35/sheet/complainthome/complainthome.do?method=showDetailPageByGreenNo&greenNo=20200623xs6
返回detail.jsp
代码如下
ComplaintHomeAction类中
public ActionForward showDetailPageByGreenNo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception{
IMainService iMainService =
(IMainService)ApplicationContextHolder.getInstance().getBean("iComplaintHomeMainManager");
String greenNo = StaticMethod.null2String(request.getParameter("greenNo"));
if(!greenNo.equals("")){
List list = iMainService.getMainListByParentSheetId(greenNo);
if(list!=null && list.size()>0){
BaseMain baseMain = (BaseMain) list.get(0);
request.setAttribute("sheetKey", baseMain.getId());
String beanName = mapping.getAttribute();
IBaseSheet baseSheet = (IBaseSheet) getBean(beanName );
baseSheet.showDetailPage(mapping, form, request, response);
return mapping.findForward("detail");
}else{
BocoLog.info(this, "不存在工单号为:"+greenNo+"的工单!");
return mapping.findForward("error");
}
}else{
BocoLog.info(this, "工单号不能为空!");
return mapping.findForward("error");
}
}
struts配置文件如下 struts-config-sheet-complainthome.xml
<action path="/complainthome"
type="com.boco.eoms.sheet.complainthome.webapp.action.ComplaintHomeAction"
name="multiPageForm" scope="request" input="error" parameter="method"
unknown="false" validate="false" attribute="Complainthome">
<forward name="detail"
path="/WEB-INF/pages/wfworksheet/complainthome/detail.jsp"
redirect="false" contextRelative="true" />
</action>
问题描述:
1、两种工单数据呈现在同一个列表中,根据工单号下钻获取详情。
例如,获取其中一类工单url为
http://10.101.214.121:9080/eoms35/sheet/complaint/complaint.do?method=showDetailPageByGreenNo&greenNo=20200702ceshi5
如果是另外一种工单,工单号为20200623xs6,url本应该是
http://10.101.214.121:9080/eoms35/sheet/complainthome/complainthome.do?method=showDetailPageByGreenNo&greenNo=20200623xs6
但由于两种工单放在同一个列表中,是用的同一个url:http://10.101.214.121:9080/eoms35/sheet/complaint/complaint.do?method=showDetailPageByGreenNo&greenNo=
所以,当获取20200623xs6的详情,就需要重定向到
http://10.101.214.121:9080/eoms35/sheet/complainthome/complainthome.do?method=showDetailPageByGreenNo&greenNo=20200623xs6
ComplaintAction类中showDetailPageByGreenNo方法中增加判断代码
else if (listComplaintHome != null && listComplaintHome.size() > 0) {
//获得此工单main表id,并存在request中。
// BaseMain baseMain = (BaseMain) listComplaintHome.get(0);
// request.setAttribute("sheetKey", baseMain.getId());
// String beanName = mapping.getAttribute();
// IBaseSheet baseSheet = (IBaseSheet) getBean("ComplaintHome");
// baseSheet.showDetailPage(mapping, form, request, response);
// ActionForward forward = mapping.findForward("showDetailPageByGreenNo");
ActionForward forward = new ActionForward("complainthome.do?method=showDetailPageByGreenNo&greenNo="+greenNo);
forward.setRedirect(true);
return forward;
struts配置文件 struts-config-sheet-complaint.xml 中增加
<action path="/complainthome"
type="com.boco.eoms.sheet.complainthome.webapp.action.ComplaintHomeAction"
name="ComplaintHome" scope="request" input="error" parameter="method"
unknown="false" validate="false">
<set-property property="cancellable" value="true" />
<forward name="detail"
path="/WEB-INF/pages/wfworksheet/complainthome/detail.jsp"
redirect="false" contextRelative="true" />
</action>
请求URL http://10.101.214.121:9080/eoms35/sheet/complaint/complaint.do?method=showDetailPageByGreenNo&greenNo=20200623xs6
页面跳转到了http://10.101.214.121:9080/eoms35/sheet/complaint/complainthome.do?method=showDetailPageByGreenNo&greenNo=20200623xs6
而想要的效果是重定向请求到http://10.101.214.121:9080/eoms35/sheet/complainthome/complainthome.do?method=showDetailPageByGreenNo&greenNo=20200623xs6
只有200积分,请求大神给与解答下奥