做的一个小东西 流程是这样的  添加一本书 添加成功之后马上查询出刚插入的图书ID 因为是自增长列
 然后action中返回 字符串 addbook  配置文件中、
<result name="addbk" type="redirectAction">bookquerybk.action?idstr=  请问这边要怎么写 
action 中才能接受到值 action中封装了 idstr 因为查询图书详情的时候是传一个字符串过来 然后再转换的  所以定义成了String类型
部分代码如下
action中的属性
private String idstr;有get set 方法
先是添加书籍 如果成功则返回addbk
查询一本书详情的方法
 public String querybk() {
         if (idstr != null || !"".equals(idstr)) {
System.out.println("idstr is "+idstr);
id = Integer.parseInt(idstr);
bk = bd.bookDetail(id);
btlist = bd.bt();
} else {
        error = "抱歉 !系统出错了";
return "querybkerror";
}
return "querybk"; }现在就是问 配置文件怎么配置
在线等啊!!!!

解决方案 »

  1.   

    没这样传过值呀,路劲后面绑参数只在页面向后台传参中见到,从后台向前面传值只需要将参数放到内置对象中就可以了呀(request、session.....)。
      

  2.   

    <result name="toshowhospital" type="redirect">hospital_showHospital.action?updateidd=${updateidd}
    </result>
    这样是可以传的
      

  3.   


    <result name="addbk" type="redirect">bookquerybk.action?idstr=${idstr} </result>
    这句话会找到你bookquerybk对应的action
      

  4.   

    如果是hibernate插入的可以直接接受返回对象能拿到。。object xx = (object) hibernateDaoTim*****.merge();
      

  5.   

    <action name="sec" class="com.xaccp.action.SecondAction">
    <result name="success">/index.jsp</result>
    <result name="haha">/haha.jsp?param=${myparam}</result>
    </action>private String myparam;public String haha() {
    System.out.println("haha"); Map<String, Object> map = new HashMap<String, Object>();
    map.put("myparam1", new DownloadAction());
    map.put("myparam2", 123);
    map.put("myparam3", "abc");
    ActionContext.getContext().setParameters(map);
    ActionContext.getContext().put("myparam4", "myparam4的value已经拿到"); myparam = "abcdefg";
    return "haha";
    }public String getMyparam() {
    return myparam;
    }public void setMyparam(String myparam) {
    this.myparam = myparam;
    }