jsp 中:
<bean : write 就可以在画面显示了

解决方案 »

  1.   

    package hello;
    public class PersonBean {    private String userName = null;    public String getUserName() {
            return this.userName;
        }
        public void setUserName(String userName) {
            this.userName = userName;
        }    /**
         * This is a stub method that would be used for the Model to save
         * the information submitted to a persistent store. In this sample
         * application it is not used.
         */
        public void saveToPersistentStore() {        /*
             * This is a stub method that might be used to save the person's
             * name to a persistent store(i.e. database) if this were a real application.
             *
             * The actual business operations that would exist within a Model
             * component would depend upon the requirements of the application.
             */
        }
    }
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %><html:html locale="true">
      <head>
        <title><bean:message key="hello.jsp.title"/></title>
        <html:base/>
      </head>
      <body bgcolor="white"><p>    <h2><bean:message key="hello.jsp.page.heading"/></h2><p>   <html:errors/><p>     <logic:present name="personbean" scope="request">
           <h2>
             <bean:message key="hello.jsp.page.hello"/>
             <bean:write name="personbean" property="userName" />!<p>
           </h2>
        </logic:present>    <html:form action="/HelloWorld.do" focus="userName" >      <bean:message key="hello.jsp.prompt.person"/>
          <html:text property="userName" size="16" maxlength="16"/><br>      <html:submit property="submit" value="Submit"/>
          <html:reset/>    </html:form><br>    <html:img page="/struts-power.gif" alt="Powered by Struts"/>  </body>
    </html:html>