1

设置属性

public class VoucherApproverListAction extends ActionSupport implements
SessionAware, ServletRequestAware, Preparable {
private HttpServletRequest servletRequest;

    public HttpServletRequest getServletRequest() {
        return servletRequest;
    }


    @Override
    public void setServletRequest(HttpServletRequest servletRequest) {
        this.servletRequest=servletRequest;
    }

public void prepare() throws Exception {
servletRequest.setAttribute("id",tCaseVouchrDto.getId());
}
}

获取属性

 public class VoucherAction extends ActionSupport implements
    SessionAware, ServletRequestAware, Preparable {
    private HttpServletRequest servletRequest;

        public HttpServletRequest getServletRequest() {
            return servletRequest;
        }


        @Override
        public void setServletRequest(HttpServletRequest servletRequest) {
            this.servletRequest=servletRequest;
        }

    public void prepare() throws Exception {
   String paramValue = (String)servletRequest.getAttribute("id");
        logger.info("@-----Id===-----@" + paramValue);
    }
    }

成功后从VoucherApproverListAction动作类重定向到VoucherAction动作类获取nullparamValue

4

1 回答 1

1

成功后从 VoucherApproverListAction 动作类重定向到 VoucherAction 动作类

这就是问题所在,如果您发送重定向,请求属性会丢失。您需要在下一个请求之前传递一个参数或将其保存在会话中。

于 2013-02-07T11:12:00.963 回答