首页 新闻 会员 周边 捐助

jsp 无法获取到 request.setAttribute 的值,在线等,,为啥异常说找不到呢,,明明设置了

0
悬赏园豆:20 [已关闭问题] 关闭于 2017-08-25 11:10

struts

spring

action

@SuppressWarnings("unused")
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {
    javax.servlet.http.HttpSession session = request.getSession(false);
    if (session == null)
        session = request.getSession(true);
    String validate = (String) request.getAttribute("GLOBE_VALIDATE");
    String invs = Pattern.compile("[^0-9,,]").matcher(request.getParameter("selinv")).replaceAll("");
    String invid[] = invs.split(",");
    Invoiceinfo invoiceinfo=null;
    Invoiceinfo invoiceinfotwo=null;
    ActionForward forward = null;
    String message = null;
    boolean messageFlag = false;
        invoiceinfo = invoiceinfohcDao.findById(String.valueOf(invid[0]));
        invoiceinfotwo=invoiceinfohcDao.findById(String.valueOf(invid[1]));
             //发票购销方税号一致,名称一致
            if((invoiceinfo.getGfmc()).equals(invoiceinfotwo.getGfmc()) && (invoiceinfo.getXfmc()).equals(invoiceinfotwo.getXfmc())
                    && (invoiceinfo.getEnterpriseid()).equals(invoiceinfotwo.getEnterpriseid()) && (invoiceinfo.getDistributiontaxnumber()).equals(invoiceinfotwo.getEnterpriseid())){
                try {
                    if (invoiceinfo.getBz()!=null && invoiceinfo.getBz().equals(invoiceinfotwo.getBz())) {//发票备注流水号一致
                        invoiceinfohcDao.updateHcById(String.valueOf(invoiceinfo.getId()));
                        invoiceinfohcDao.updateBySN(invoiceinfo.getBz());
                        /*request.setAttribute("message", "解决红冲异常成功!!");
                        forward = mapping.findForward("default");*/
                        messageFlag = false;
                        message = (new StringBuilder("解决红冲异常成功!!")).toString();
                        
                    }else{
                        invoiceinfohcDao.updateHcById(String.valueOf(invoiceinfo.getId()));
                        /*request.setAttribute("message", "解决红冲异常成功!!");
                        forward = mapping.findForward("default");*/
                        messageFlag = false;
                        message = (new StringBuilder("解决红冲异常成功,未发现流水号,流水号信息未更新!!")).toString();
                    }
                } catch (Exception e) {
                    /*request.setAttribute("message",e.getMessage());
                    forward = mapping.findForward("default");*/
                    messageFlag = false;
                    message = (new StringBuilder("解决红冲异常失败!系统异常!")).append(
                            e.getMessage()).toString();
                }
            }else{
                /*request.setAttribute("message","解决红冲异常失败!发票异常!!");
                forward = mapping.findForward("default");*/
                messageFlag = false;
                message = (new StringBuilder("解决红冲异常失败!发票异常!!")).toString();
            /*    ActionMessages messages = new ActionMessages();
                messages.add("org.apache.struts.action.GLOBAL_MESSAGE",
                        new ActionMessage("解决红冲异常失败!发票异常!!"));
                saveMessages(request, messages);*/
            }
            request.setAttribute("informessageMsg", message);
            System.out.println(message);
    return mapping.findForward("success");
}

jsp

    <span class="hrMsg"><bean:write name="informessageMsg"  scope="request" /></span>

<span class="hrMsg"><bean:write name="informessageMsg"  scope="request"/></span>

Vip灬cnblog的主页 Vip灬cnblog | 初学一级 | 园豆:133
提问于:2017-08-16 17:44
< >
分享
所有回答(2)
0

我不懂java语法,但是从名字上来看,request.setAttribute应该是给某个东西设置值,是否取值应该用类似于request.getAttrubutute的语法。

龙行天涯 | 园豆:1794 (小虾三级) | 2017-08-17 13:46
0

是请求的request 对象,,和返回的request 的对象,, 不是同一个对象

Vip灬cnblog | 园豆:133 (初学一级) | 2017-08-25 11:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册