Struts 2.1 简单示例(手写)
对于技术原理不作解析, 我的目标是让需要的朋友能一次性成功完成自己的第一个Struts 2.1项目.
?
1. 添加Apache Struts 2.1.6库
?
commons-fileupload-1.2.1.jar
commons-logging-api-1.1.jar
freemarker-2.3.13.jar
ognl-2.6.11.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jar
?
与Struts 2.0相比, 多了commons fileupload.
下载地址: http://struts.apache.org/download.cgi#struts216
?
2. 在web.xml中配置FilterDispatcher
?
??
3. 编写HiAction
?
??
hi.jsp:
?
?
?
5. 编写struts.xml
?
??
附件为项目编译版, 可部署至Tomcat运行, 以查看运行效果.
如有不到之处, 请一定批评指正. 非常感谢!!!
1 楼 t414789324 2010-07-13 搞了一下午都报错,果然 根据你这个来 没有错 但是 自己的错误原因 还是没解决,遗憾 2 楼 sam_kee 2010-12-03 哎,我遇到莫名奇怪的错误,自己自定义的拦截器,就会报
2010-12-3 20:48:09 com.opensymphony.xwork2.util.logging.commons.CommonsLogger wa
rn
警告: Unable to load config class ch5.SimpleInterceptor at interceptor - file:/D
:/Tomcat%206.0/webapps/struts_chengxutianxia/WEB-INF/classes/ch5/ch5.xml:8:71 pr
obably due to a missing jar, which might be fine if you never plan to use the si
mpleInterceptor interceptor
2010-12-3 20:48:09 com.opensymphony.xwork2.util.logging.commons.CommonsLogger er
ror
严重: Actual exception
Caught Exception while registering Interceptor class ch5.SimpleInterceptor - int
erceptor - file:/D:/Tomcat%206.0/webapps/struts_chengxutianxia/WEB-INF/classes/c
h5/ch5.xml:8:71
at org.apache.struts2.impl.StrutsObjectFactory.buildInterceptor(StrutsOb
jectFactory.java:77)
at com.opensymphony.xwork2.config.providers.InterceptorBuilder.construct
InterceptorReference(InterceptorBuilder.java:59)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loo 3 楼 sam_kee 2010-12-03 哈哈,找到答案了,由于我的名字起错了,原先我的类名是SimpleInterceptor.java,我把它改了,后来tomcat就不报错了