struts1的问题,急急急!

idwendy 2013-09-10 07:39:17
巴巴运动网项目 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;
}

}
...全文
194 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Qimat77 2014-03-24
  • 打赏
  • 举报
回复
报404错误就是没找到资源路径啊,一般都回去查看浏览器地址或者path路径对不对、
idwendy 2013-09-14
  • 打赏
  • 举报
回复
引用 1 楼 u011941407 的回复:
项目名称是不是忘带了 http://localhost:8000/项目名称/user/reg.do?method=regUI
的确是啊,忘记把项目的context root改成空了
idwendy 2013-09-14
  • 打赏
  • 举报
回复
引用 2 楼 fudongrifdr 的回复:
目测就是没带项目名。。
的确是啊,忘记把项目的context root改成空了
末日哥 2013-09-13
  • 打赏
  • 举报
回复
目测就是没带项目名。。
zmj491998167 2013-09-13
  • 打赏
  • 举报
回复
项目名称是不是忘带了 http://localhost:8000/项目名称/user/reg.do?method=regUI

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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