Topic: 关于struts的几个问题请教 |
Print this page |
1.关于struts的几个问题请教 | Copy to clipboard |
Posted by: nykey Posted on: 2005-01-31 12:27 我的主要工具:tomcat+eclipse 第一个:struts标签如何写,我写了一个,但是页面显示出来的空白,程序如下: <%@page contentType="text/html;charset=GB2312"language="java"%> <%@taglib uri="/WEB-INF/struts-bean.tld"prefix="bean"%> <%@taglib uri="/WEB-INF/struts-html.tld"prefix="htem"%> <%@taglib uri="/WEB-INF/struts-logic.tld"prefix="logic"%> <%@taglib uri="/WEB-INF/struts-template.tld"prefix="template"%> <html:html> <head><title>simple struts!</title></head> <body bgColor=white> <html:base/><html:form method="post" action="/HelloWorldAction.do"> <html:text property="mybeanvariabled"/><html:submit value="enter"/> <html:reset value="reset"/> </html:form> </body> </html:html> 第二个:actionservlet如何启动呢? web.xml是这样定义的 <?xml version="1.0"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> <web-app> <!-- Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- The Welcome File List --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- Struts Tag Library Descriptors --> <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> <taglib> <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri> <taglib-location>/WEB-INF/struts-template.tld</taglib-location> </taglib> </web-app> struts-config.xml的配置如下: <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"> <struts-config> <form-beans> <form-bean name="HelloWordForm"type="HelloWordForm" /> </form-beans> <action-mappings> <action path="/HelloWordAction" type="HelloWordAction" name="HelloWordForm" scope="session" input="/HelloWord.jsp"> <forward name="success" path="/out.jsp" /> <forward name="failure" path="error.jsp"/> </action> </action-mappings> </struts-config> 问题如下:tomcat启动过程中一切正常,但是一旦要进入一旦传送HelloWorldAction.do系统提示错误:servlet is not avariable! 请问这到底是什么原因造成的呢?我都是按照网上的实例来配置的,为什么还会出现这样的问题呢? |
2.Re:关于struts的几个问题请教 [Re: nykey] | Copy to clipboard |
Posted by: mutu Posted on: 2005-02-02 14:25 <html:form method="post" action="/HelloWorldAction.do">里面的"/HelloWorldAction.do" 改成"/HelloWordAction"试试。要和path="/HelloWordAction" 里面的对应 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |