其实在action 里的excute方法里可以用request.getParameter(id);就可以获得id对应的那个对象了,是不是你的那个localhost/topic.jsp?id=10 写错了,应该是localhost/根目录/topic.jsp?id=10吧 ..先顶一下

解决方案 »

  1.   

    action 里的excute方法里可以用request.getParameter(id)
      

  2.   

    要想调用struts所有的请求必须为*.do的形式(当然也可以自己定义),
    也就是说你所发出的/topic.jsp?id=10这个请求要改为*.do?id=10,(*代表struts-config.xml配置文件中对应的action的path值)
    struts中要有一个表单bean与一个action对应,
    比如InfoFrom,
    public class InfoForm{
      private int id;
      public void setId(int id){
        this.id = id;
      }
      public int getId(){
        return this.id;
      }
    }
    在对应的action中的excute()方法里,
    比如InfoAction,
    ...
      public ActionMapping excute(参数略){
        InfoForm form = (InfoForm)form;//将参数中的form强制转换为InfoForm;
        int id = form.getId();//请求的参数id会被struts自动封装成InfoForm,这里直接通过form去取;
    }