以下是我的JSP页面:
<body>
        <%
     if(application.getAttribute("count")==null){
     application.setAttribute("count","1");
     out.println("first user");
     out.print(application.getAttribute("count"));
     }
     else{
     int a=Integer.valueOf((String)application.getAttribute("count"));
     application.setAttribute("count",Integer.toString(a+1));
     out.print(application.getAttribute("count"));
     }
      %>
  </body>
我想把这些代码用struts分离开,可是不知道这些代码往哪里写了,麻烦大哥帮我一下,最好有详细的代吗,有的人告诉我说写一个bean,可是这个bean怎么写呀?

解决方案 »

  1.   

    1楼正解,可以用struts提供的标记来完成...
      

  2.   

    同意一楼说法,用struct中的标签就能解决了
      

  3.   

    建议你不要在JSP页面进行增减操作,在ACTION里面操作好了再传回给页面即可,这样就能直接取回,如果没有count的存在则显示1,有就显示count的值<c:out value="${count}" default="1"></c:out>或者用BEAN标签:<logic:notPresent name="count">
      <c:out value="1"></c:out>
    </logic:notPresent>
     <logic:present name="count">
      <bean:write name="count" />
    </logic:present>
      

  4.   

    直接新建一个JSP  FORM  ACTION,以后的页面不要业务 或者事物代码。