日期:2014-05-18  浏览次数:20594 次

一个简单的struts例子 遇到无法解决的问题
jsp文件:文件名:hello.jsp

<%@   page   language= "java "   import= "java.util.* "   pageEncoding= "GBK "%>
<%@   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 "%>

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN "   "http://www.w3.org/TR/html4/loose.dtd ">


<htm:html   local= "true ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<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 "   propert= "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 "/>

<html:submit   property= "submit "   value= "Submit "> </html:submit>

<html:reset> </html:reset>
</html:form> <br>

<html:img   page= "/struts-power.gif "   alt= "Powered   by   Struts "/>


</body>
</htm:html>

struts-config.xml文件:

<?xml   version= "1.0 "   encoding= "ISO-8859-1 "?>
<!DOCTYPE   struts-config   PUBLIC   "-//Apache   Software   Foundation//DTD   Struts   Configuration   1.1//EN "   "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd ">

<struts-config>
    <data-sources   />
        <form-beans>
    <form-bean   name= "HelloForm "   type= "hello.HelloForm "> </form-bean>
   
    </form-beans>
    <global-exceptions   />
    <global-forwards   />
    <action-mappings   >
            <!--   Say   Hello!   -->
           
            <action   path= "/HelloWorld "  
                type= "hello.HelloAction "
                name= "HelloForm "
          &n