浏览 1641 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2008-04-03
文件名:helloWorld.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page language="java"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <form name="form1" action="/helloworld.do" method="post"> <input type="text" name="name"/> <input type="submit" value="ok"/> </form> </body> </html> 文件名web.xml: <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>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> 文件名:HelloAction.java 继承Action package Simple_func; import org.apache.struts.action.*; import javax.servlet.http.*; public class HelloAction extends Action{ public ActionForward execute (ActionMapping mapping , ActionForm form, HttpServletRequest request,HttpServletResponse response ){ HelloForm hello_form = (HelloForm)form; String name = hello_form.getName(); return mapping.findForward("hello"); } } 文件名:HelloForm 继承ActionForm package Simple_func; import org.apache.struts.action.ActionForm; public class HelloForm extends ActionForm{ private String name; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } } structs配置文件: <struts-config> <form-beans> <form-bean name="helloWorldForm" type="Simple_fun.HelloForm"/> </form-beans> <action-mappings> <action path="/test" type="Simple_func.Test" scope="request" > <forward name="index" path="/WEB-INF/index.jsp"/> </action> </struts-config> 出现的问题: 好象ActionServlet拦截不到 .do请求, url直接转到了 :localhost:8080/helloWorld.do 而且出现找不到文件. 就感觉我的ActionServlet根本没有去拦截请求.... 真的不得已才麻烦大家, google上就一个类似问题,而且还没有得到解决. 我已经在struts的第一的程序上花费3天时间了,希望大家能帮我一把, 谢谢! 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-04-03
希望有人能够不吝赐教!~~~
|
|
返回顶楼 | |
发表时间:2008-04-04
最好的老师还是自己,已经解决了
|
|
返回顶楼 | |