action 代码:public ActionForward update(ActionMapping mapping, ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
response.setContentType("text/html;charset=gb2312");
        PrintWriter out = response.getWriter();
System.out.println("测试===============");
InventoryManager mgr = (InventoryManager) getBean("inventoryManager");
InventoryForm InventoryForm = (InventoryForm) form;
String[] cinvCodes = request.getParameterValues("cinvCode");  
        String[] cInvPersonCodes = request.getParameterValues("cInvPersonCode");
        String[] iAdvanceDates = request.getParameterValues("iAdvanceDate");  
        String[] fMinSupplys = request.getParameterValues("fMinSupply");  
        String[] fSupplyMultis = request.getParameterValues("fSupplyMulti");  
        String[] bPurchases =request.getParameterValues("bPurchase");
        String[] bSelfs = request.getParameterValues("bSelf");
        String[] cPurPersonCodes =  request.getParameterValues("cPurPersonCode");
        String[] cInvStds =  request.getParameterValues("cInvStd");
        String[] cInvAddCodes =  request.getParameterValues("cInvAddCode");
        ActionMessages act = new ActionMessages();
        ActionMessages errors = new ActionMessages();
        Inventory in = new Inventory();
        int a = 0;
        int b = 0;
        boolean bPurchase = false;
        boolean bSelf = false;
      
        for(int i = 0;i<cinvCodes.length;i++){
         if(Integer.parseInt(bPurchases[i])==1){
         bPurchase = true;
         }
         if(Integer.parseInt(bSelfs[i])==1){
         bSelf = true;
         }
           System.out.println("------"+cinvCodes[i]);
       // mgr.updateInventory(cInvPersonCodes[i], iAdvanceDate, fMinSupply, fSupplyMulti, bPurchase, bSelf, cPurPersonCode, cInvStd, cInvAddCode, cinvCode)
           Inventory inv = mgr.getInventory(cinvCodes[i]);
           if(inv==null){
           System.out.println("第" + i + "条数据插入失败");
           act.add("error1", new ActionMessage("'第''"+i+"''条数据更新失败,原因:编码不存在'"));
           //out.println("'第''"+i+"''条数据更新失败,原因:编码不存在'");
           a++;
           }else{
           mgr.updateInventory(cInvPersonCodes[i], Integer.parseInt(iAdvanceDates[i]),
         Integer.parseInt(fMinSupplys[i]),Integer.parseInt(fSupplyMultis[i]), bPurchase, bSelf,
         cPurPersonCodes[i], cInvStds[i], cInvAddCodes[i], cinvCodes[i]);
              b++;
           }
           }
        act.add("success1", new ActionMessage("失败条数:'"+a+"'",false));
        act.add("success2", new ActionMessage("成功条数:'"+b+"'",false));
        System.out.println("失败条数==="+a);
        System.out.println("成功条数==="+b);
        request.setAttribute("msg", act);
        return mapping.findForward("update");
}请问:

如何在jsp中用<html:message>获取action中ActionMessages的值 并打印出来呢

解决方案 »

  1.   


    没人么
    我忘记怎么用struts标签了
    在网上查也没找到具体的实例
      

  2.   

    貌似是在标签里用property属性指定,记不太清了,自己试一下
      

  3.   

    已解决:
    <html:messages id="su" name="msg" property="success1">
       <bean:write name="su" />
     </html:messages><br/>
      
      <html:messages id="d" name="mess" property="success2">
       <bean:write name="d" />
      </html:messages><br/>
      
      <c:forEach var="stu" items="${errors}">
    ${stu}
    </c:forEach>