request.getAttribute为什么取出来的值是空,高分在线等

来源:百度知道 编辑:UC知道 时间:2024/06/18 12:16:12
我用struts+spring+ibatis做的项目,代码如下
action:
package com.nuage.console.product.action;

public class ProductAction extends BaseAction {
public ActionForward product(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse responsee) throws ConsoleException{
ProductLogic productLogic = (ProductLogic)this.getBean("ProductLogicImpl");
String onPage = request.getParameter("onPage");
int onPageInt = onPage == null?1:Integer.parseInt(onPage);
List<ProductVO> productList = productLogic.sqlAll();
PageVO pageVO = PageUtil.getPageList(productList, 10, onPageInt);
request.setAttribute("pageVO", pageVO);
return mapping.findForward("product");
}

public ActionForward insert(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)throws Exception{
ProductLogic productLogic = (P

mapping.findForward("save");
只要你是forwar在struts-config.xml的跳转中没有让它重定向
比如<forwar name="save" path="....." redirect="true">就不行了把
redirect="false"楼主试试
——————————————————————————————————————
<forward name="save" path="/pages/product/MyJsp.jsp"></forward>
path="/pages/product/product_update.jsp"></forward> 改为
<forward name="save" path="/pages/product/MyJsp.jsp"></forward> 楼主你说的Myjsp是空白页面,那不行的request只能跳转一次,除非你的空白页面跳转到product_new.jsp也是用到forward而不是重定向request.sendirect()

1.请确保你存值的时候key="flag",取值的时候也没有必要强行类型转换,本来就是String的.

2.请确保你的struts-config.xml 中save这个forward没有redirect属性,如果有请删除.

3."以前也都是这么写的 也能刷新,怎么就这次不能了 ",
<%
String flag = (String)request.getAttribute("flag");
if("true".equals(flag)){
%>
window.opener.location.re