在第4步之前,在action中写:
request.setAttribute("username",用户名的值);
request.setAttribute("password",用户密码的值);然后,在index.jsp中写:
<bean:write name="username"/>
<bean:write name="password"/>

解决方案 »

  1.   

    不是说forward的时候会把FormBean forward到目标页么?为什么还要再次setAttribute呢?我不能直接取吗?比如:<bean:write name="FormBean" property="username"/>
    我这样写,错了。但是我想知道我这种方法行不行?
      

  2.   

    可以阿,只要在jsp  <html:html> 上面加上<jsp:useBean id="FormBean" scope="session" type="jp.co.xx.xx.xx.FormBean"/>type 就是你FormBean的类型。看看如何
      

  3.   

    你可以在form中加上两个属性username,password
    然后action中用set()把属性设置
    页面上就可以用Struts标签了<bean:write name="struts配置文件中对应的form" property="在form中的属性名"/>如果调试出来记得给我JF
      

  4.   

    假设:你的form bean的名称是FormBean;那么当你的程序forward到jsp页面时,你可以在jsp中使用<bean:write name="FormBean" property="username"/>来获取FormBean中所承载的数据。楼上的兄弟,不需要在对应于FormBean的Action中进行set操作,FormBean全程跟随scope所指定的范围,不会消失的(除非超出scope指定范围)。
      

  5.   

    楼上二位大哥好!感谢帮助!feverheat的帮助挺到位,不过mhw1010大哥说的也很正确!谢谢!