类似这样的调用<a href="/test.action?id=1">test</a>
在action类中用request.getParameter("id")为何得不到参数值?
action类中已经implements ServletRequestAware谢谢。

解决方案 »

  1.   

    extends DispatchAction 试试
      

  2.   

    得到的是NULL值,还是怎么样的啊,是不是没有得到request的请求啊,test.action里面看看,是否跳转过去了。
      

  3.   

    HttpServletRequest request, HttpServletResponse response) {
    LoginForm loginForm = (LoginForm) form;// TODO Auto-generated method stub
    // String id = loginForm.getPassword();
    String id = "123";
    IBcGoodsService service = (IBcGoodsService) getBean("BcGoodsService");
    BcGoods bcGoodsFormDB = service.getBcGoodsByid(Long.valueOf(id)); List<BcGoods> list = service.findAll();

    // System.out.println(bcGoodsFormDB.getImg());
    // for (BcGoods goods : list) {
    // System.out.println(goods.getName());
    // }
    // if (bcGoodsFormDB.getName().equals(BcGoodsname)) {
    request.setAttribute("bcGoodsFormDBImg", bcGoodsFormDB.getImg());
    request.setAttribute("bcGoodsFormDB", list); return mapping.findForward("success");
    // }
    // return mapping.findForward("false");
    }
    }lz继承的action不了解 ,附上代码共参考  关注
      

  4.   

    用ActionForm的Mapping来解决吧
    mapping.findForward("id");
      

  5.   

    没理由呀。
    用 <a href="<s:url action="mselectdownload"><s:param name="tag" value="m"/></s:url>">信息发布</a>
    这种形式看看
      

  6.   


    我用的是Struts2,你的是Struts1中的。
    我的类是这样
    ...extends ActionSupport implements ServletRequestAware {    ...method() {
            String id = request.getParameter("id"); //null值,为什么?
        }}
      

  7.   

    <a href="/test.action?id=1">test </a>public class 类 implements Action{ private int id;              public int getId(){
    return this.id;
    } public void setId(int id){
    this.id = id;
    } public String execute() throws Exception{
    return SUCCESS;
    }}接收页面直接用${id}即可获取
      

  8.   

    问题算是解决了。
    在JDeveloper中,死活得不到传过来的参数值。
    同样的代码,拷到Eclipse中运行,就能得到。
    可能是oc4j服务器的问题,也可能是Jdeveloper的版本号低(10.1.3.1)与运行环境不兼容导致。感谢。
      

  9.   

    <s:url action="test.action" id="abc">
    <s:param name="id">1</s:param>
    </url>
    要这么传!~