struts1.3关于struts-config.xml的一个问题

idwendy 2013-09-11 02:15:40
巴巴运动网项目 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;
}

}
...全文
163 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
idwendy 2013-09-11
  • 打赏
  • 举报
回复
引用 5 楼 rainbowsix 的回复:
springMVC 跟struts1混用?太有才了。
不是我这样用,是以前的项目“巴巴运动网”教程,再说没用springMVC,总体的框架式spring+struts+JPA
无聊找乐 2013-09-11
  • 打赏
  • 举报
回复
springMVC 跟struts1混用?太有才了。
idwendy 2013-09-11
  • 打赏
  • 举报
回复
引用 2 楼 haikuotiankong1997 的回复:
你的工程内容好像也有错误,到网上看看struts和spring集成的例子。
以前用的是struts2+spring3.0比较,这个项目的版本较低,不是很熟悉//
idwendy 2013-09-11
  • 打赏
  • 举报
回复
引用 1 楼 haikuotiankong1997 的回复:
---警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:shop_01' did not find a matching property.-- 把tomcat去掉,重新添加一个,再把工程部署上去。
不行,试了好几遍了
haikuotiankong1997 2013-09-11
  • 打赏
  • 举报
回复
你的工程内容好像也有错误,到网上看看struts和spring集成的例子。
haikuotiankong1997 2013-09-11
  • 打赏
  • 举报
回复
---警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:shop_01' did not find a matching property.-- 把tomcat去掉,重新添加一个,再把工程部署上去。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧