买了本书“程序天下 J2EE整合详解与典型案例一本书搞定”,按照书上的说明,配置好了程序,但运行后总出现如下错误:HTTP Status 404 - /jsp/myEdition/index.do--------------------------------------------------------------------------------type Status reportmessage /jsp/myEdition/index.dodescription The requested resource (/jsp/myEdition/index.do) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.16其中jsp位虚拟目录,myEdition为程序所在文件夹,请帮我分析一下这是为什么啊,谢谢!
--------------------------------------------------------------------------------Apache Tomcat/6.0.16其中jsp位虚拟目录,myEdition为程序所在文件夹,请帮我分析一下这是为什么啊,谢谢!
看楼主的代码,应该是用struts1写的吧,
你可以检查一下路径(包括映射文件中的路径设置)
看看是不是路径错了
建议你检查一下你的struts的配置文件,着重看一下你的action路径是怎么设置的
还有就是你的前台页面请求action是否匹配
<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>actionServlet</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>
<load-on-startup>1</load-on-startup>
</servlet>
<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>
<!--处理所有后缀为do的请求-->
<servlet-mapping>
<servlet-name>actionServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--对编码进行过滤-->
<filter>
<filter-name>SetCharacterEncoding</filter-name>
<filter-class>com.myEdition.action.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<!--处理所有后缀为do的请求-->
<filter-mapping>
<filter-name>SetCharacterEncoding</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
</web-app>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<!--定义formbean-->
<form-beans><form-bean name="user" type="com.myEdition.bean.User"/>
<form-bean name="contentType" type="com.myEdition.bean.ContentType"/>
<form-bean name="content" type="com.myEdition.bean.Content"/>
</form-beans>
<action-mappings>
<!--定义和SPring配置文件相同的路径-->
<action path="/regedit" type="org.springframework.web.struts.DelegatingActionProxy" name="user">
<forward name="regedit" path="/jsp/regedit.jsp"/>
</action>
<!--定义初次访问时的路径-->
<action path="/input"
type="org.apache.struts.actions.ForwardAction"
parameter="/jsp/regedit.jsp"/>
<!--定义和SPring配置文件相同的路径-->
<action path="/login"
type="org.springframework.web.struts.DelegatingActionProxy" name="user">
<forward name="success" path="/jsp/type.jsp"/>
<forward name="login" path="/jsp/login.jsp"/>
</action>
<!--定义初次访问时的路径-->
<action path="/loginTemp"
type="org.apache.struts.actions.ForwardAction"
parameter="/jsp/login.jsp"/>
<action path="/setType"
type="org.springframework.web.struts.DelegatingActionProxy" name="contentType">
<forward name="success" path="/jsp/type.jsp"/>
</action>
<action path="/release"
type="org.springframework.web.struts.DelegatingActionProxy" name="content">
<forward name="success" path="/jsp/edit.jsp"/>
</action>
<action path="/edit"
type="org.springframework.web.struts.DelegatingActionProxy" name="content">
<forward name="success" path="/jsp/edit.jsp"/>
</action>
<action path="/index"
type="org.springframework.web.struts.DelegatingActionProxy" >
<forward name="success" path="/jsp/index.jsp"/>
</action>
</action-mappings>
<!--注册ContextLoaderPlugIn插件-->
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/spring-config.xml" />
</plug-in>
</struts-config>
或者请求时用全路径
<action path="/index"
type="org.springframework.web.struts.DelegatingActionProxy" >
<forward name="success" path="/jsp/index.jsp"/>
</action>
仔细看你这两个地方
比较得知是路径错了
路径有两种写法
1.
<form action="index.do">
2.
<form action="/(工程名或者是WEB-INF文件夹父文件夹的名字)/index.do">
如果工程名为erp,那写法为:
<form action="/erp/index.do">
后面那个点do可以省略不写