一个简单的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 "
scope= "request "
validate= "true "
input= "/hello.jsp ">
<forward name= "SayHello " path= "/hello.jsp "> </forward>
</action>
</action-mappings>
<message-resources parameter= "com.huazhengyangguang.struts.ApplicationResources " />
</struts-config>
web.xml文件:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<web-app xmlns= "http://java.sun.com/xml/ns/j2ee " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " version= "2.4 " xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<servlet>
<servlet-name> action </servlet-name>
<servlet-class> org.apache.struts.action.ActionServlet </servlet-class>
<init-param>
<param-name> config </param-name>
<param-value> /WEB-INF/struts-config.xml </param-value>
</init-param>
<init-param>
<param-name> debug </param-name>
<param-value> 3 </param-value>
</init-param>
<init-param>
<param-name> detail </param-name>
<param-value> 3 </param-value>
</init-param>
<load-on-startup> 0 </load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name> action </servlet-name>
<url-pattern> *.do </url-pattern>
</servlet-mapping>
<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file> hello.jsp </welcome-file>
</welcome-file-list>
<!-- Struts Tag Library Descriptors -->
<jsp-config>
<taglib>
<taglib-uri> /WEB-INF/struts-bean.tld </taglib-uri>
<taglib-location> /WEB-INF/struts-bean.tld </taglib-location>
</taglib>
<taglib>
<taglib-uri> /WEB-INF/struts-html.tld </taglib-uri>
<taglib-location> /WEB-INF/struts-html.tld </taglib-location>
</taglib>
<taglib>
<taglib-uri> /WEB-INF/struts-logic.tld </taglib-uri>
<taglib-location> /WEB-INF/struts-logic.tld </taglib-location>
</taglib>
</jsp-config>
</web-app>
错误页面:
org.apache.jasper.JasperException: /hello.jsp(24,0) Attribute propert invalid for tag write according to TLD
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
请高手给解决一下 50分赠送!
[解决办法]
<bean:write name= "personbean " propert= "userName "/> ! <p>
不是propert,是property^_^
[解决办法]
这里拼写错误:
<bean:write name= "personbean " propert= "userName "/> ! <p>
应该是property 不是propert....-_-||
错误说明已经很清楚了
[解决办法]
/hello.jsp(24,0) Attribute propert invalid for tag
是 property