我使用myeclipse开发struts一简单的注册程序 把zhuce.jsp页面放在WEB-INF/form下 如下:
<?xml version="1.0" encoding="UTF-8"?>
<!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="zhuceForm" type="com.zqswork.struts.form.ZhuceForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="zhuceForm"
input="/form/zhuce.jsp"
name="zhuceForm"
path="/zhuce"
scope="request"
type="com.zqswork.struts.action.ZhuceAction">
<forward
name="show.jsp"
path="/form/show.jsp"
redirect="true" />
</action> </action-mappings> <message-resources parameter="com.zqswork.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>
<welcome-file-list>
<welcome-file>/form/zhuce.jsp</welcome-file>
</welcome-file-list>
</web-app>但是访问的时间 我输入://127.0.0.1:8080/我的项目名
出现404错误
输入://127.0.0.1:8080/我的项目名/form/zhuce.jsp
或者
://127.0.0.1:8080/我的项目名/zhuce.jsp
都出现404错误
请问怎么回事?
<?xml version="1.0" encoding="UTF-8"?>
<!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="zhuceForm" type="com.zqswork.struts.form.ZhuceForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="zhuceForm"
input="/form/zhuce.jsp"
name="zhuceForm"
path="/zhuce"
scope="request"
type="com.zqswork.struts.action.ZhuceAction">
<forward
name="show.jsp"
path="/form/show.jsp"
redirect="true" />
</action> </action-mappings> <message-resources parameter="com.zqswork.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>
<welcome-file-list>
<welcome-file>/form/zhuce.jsp</welcome-file>
</welcome-file-list>
</web-app>但是访问的时间 我输入://127.0.0.1:8080/我的项目名
出现404错误
输入://127.0.0.1:8080/我的项目名/form/zhuce.jsp
或者
://127.0.0.1:8080/我的项目名/zhuce.jsp
都出现404错误
请问怎么回事?
路径放错了,form文件夹应该放在根目录下。
上面哪个WEB.XML的欢迎页面放错了 应该放在开始 我已修改 问题还是存在!
.....
<welcome-file-list>
<welcome-file>zhuce.jsp</welcome-file>
</welcome-file-list>
......
但是是报404错误!!!
求救呀 兄弟们
访问是输入的 :<//127.0.0.1:8080/我的项目名 >路径
<welcome-file-list>
<welcome-file>form/zhuce.jsp</welcome-file>
</welcome-file-list>
如果把这些JSP页面文件移到WEB-INF 目录下,在调用页面的时候就必须把"WEB-INF"添加到URL中。例如,在一个Struts配置文件中为一个logoff action写一个Action mapping。其中JSP的路径必须以"WEB-INF"开头。
要说明的是,并不是所有的容器都能支持这个特性。WebLogic早期的版本不能解释Servlet声明,因此无法提供支持,据报道在新版本中已经改进了。总之使用之前先检查一下你的Servlet容器。