<logic:present>标签用来判断是否存在userInfoForm对象,如果存在则输出main.jsp.welcome对应的消息(<bean:mess>标签用于输出消息)和userInfoForm的username属性(用<bean:write>标签来输出)

解决方案 »

  1.   

    <logic:present></logic:present> struts 的逻辑标签,如果存在...则...
      

  2.   

    <logic:present name="userInfoForm">//如果指定(userInfoForm)存在就计算Body的值.
    <H3>
      <bean:message key="main.jsp.welcome"/> //用于输出消息,注意这个消息在ApplicationResources.properties中定义.
      <bean:write name="userInfoForm" property="username"/>!//输出名字为userInfoForm的Bean的username属性.
    </H3>
    </logic:present>
      

  3.   

    标识userInfoForm这个对象是不是存在,要是存在再显示userInfoForm中的username属性,如果不这样写的话,要是userInfoForm会报空指针错误的
      

  4.   

    换成jsp的写法,差不多就是下面这个样子。<%
     if (userInfoForm != null){
       out.println("<H3>");
       out.println("message");//这个对应的消息,在struts-config.xml里面设置的<message-resources>里面指定的文件里面.怎么取,这里就不写了.
       out.println(userInfoForm.username);
       out.println("</H3>");
     }
    %>