struts1的问题,急急急!
巴巴运动网项目 struts1.3 tomcat7.0 jdk7.0
浏览器访问:http://localhost:8000/user/reg.do?method=regUI 提示404错误,tomcat那边一点错误提示都没有,只有一个警告不知道有没有关系
警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:shop_01' did not find a matching property.
调试了一下,感觉web.xml跳到struts-config.xml的时候好像出问题了,因为struts-config.xml的配置文件里面的传递参数我怎么改都没有错误提示,比如form-bean的name跟action的name改成不一致也不给提示报错。
整了一个下午也没个结果,急死俺了,哪位哥帮忙看下是哪里出问题了。
关键代码如下:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>struts</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>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>struts</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="buyerForm" type="cn.itcast.web.formbean.user.BuyerForm"></form-bean>
</form-beans>
<action-mappings>
<action path="/user/reg" name="buyerForm" scope="request" parameter="method">
<forward name="regUI" path="/index.jsp"></forward>
</action>
</action-mappings>
<controller>
<set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>
</struts-config>
BuyerRegAction.java
package cn.itcast.web.action.user;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.springframework.stereotype.Controller;
@Controller("/user/reg")
public class BuyerRegAction extends DispatchAction {
public ActionForward regUI(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("comein");
return mapping.findForward("regUI");
}
}
BuyerForm.java
package cn.itcast.web.formbean.user;
import org.apache.struts.action.ActionForm;
public class BuyerForm extends ActionForm {
private String username;
private String password;
private String email;
public void BuyerForm() {
System.out.print("come in"); //这里控制台没有输出,应该是没有进入这里
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
struts web.xml 跳转 tomcat7.0 spring
[解决办法]
项目名称是不是忘带了
http://localhost:8000/项目名称/user/reg.do?method=regUI
[解决办法]
目测就是没带项目名。。