巴巴运动网项目  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板块那边发帖也没人理,蛋疼啊,真的就没人会么?这个问题没解决项目做不下去啊
关键代码如下:
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;
}

}
strutstomcatweb.xmlstruts-config.xmspring

解决方案 »

  1.   

    ---警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:shop_01' did not find a matching property.--
    把tomcat去掉,重新添加一个,再把工程部署上去。
      

  2.   

    你的工程内容好像也有错误,到网上看看struts和spring集成的例子。
      

  3.   

    以前用的是struts2+spring3.0比较,这个项目的版本较低,不是很熟悉//
      

  4.   

    springMVC 跟struts1混用?太有才了。
      

  5.   

    不是我这样用,是以前的项目“巴巴运动网”教程,再说没用springMVC,总体的框架式spring+struts+JPA