如何快速地部属Struts2-学习Struts2开篇
来源:互联网 发布:网站域名没有www 编辑:程序博客网 时间:2024/05/01 01:21
如何快速地部属Struts2
开发工具-Eclipse Struts2.0
从新建Web/Dynamic Web Project开始
不说简单的了,只说几点要特别注意的
1.应用Struts2
将xwork-2.0.4.jar、commons-logging-1.0.4.jar、freemarker-2.3.8.jar、ognl-2.6.11.jar、struts2-core-2.0.11.jar这几个包copy到web程序的lib下。其它的不要。否则发布的时候会报:Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean错误
原因是:If any Struts 2 Plugins are included, then other JARs may be needed too. For example, the optional Spring Plugin requires the Spring JARs to be present.
2.部属
(1)web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Struts 2.0 Hello World</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Struts中默认的web.xml配置如上
(2)struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="tutorial" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>HelloWorld.jsp</result>
</action>
</package>
</struts>
Struts中默认的struts.xml配置如上
注:文件名必须为struts.xml
3.Action Class
继承ActionSupport(com.opensymphony.xwork2.ActionSupport)
实现execute
返回ERROR,INPUT,LOGIN,NONE,SUCCESS之一
参考:Max的Struts 2教材
- 如何快速地部属Struts2-学习Struts2开篇
- 如何快速地学习
- Struts2学习之路——开篇
- struts2开篇(一)
- 如何优雅地为Struts2的action加监控日志
- JAVA Struts2框架之开篇
- [Struts2]Struts2学习总结
- Struts2 学习
- Struts2学习
- 学习struts2
- 学习struts2
- 学习struts2
- 学习Struts2
- Struts2学习
- struts2学习
- 学习struts2
- struts2学习
- struts2学习
- asp.net实现DropDownList、ListBox无刷新三级联动的方法
- SQL中HAVING从句的用法和联结(JOIN)语法(转载)
- 利用IPC通道进行进程间通信(C#)
- 四川发生7.8级大地震,由于震动强烈,远至北京和上海都感受到震动。
- 求伯君内部邮件曝光 金山为什么一定要买楼
- 如何快速地部属Struts2-学习Struts2开篇
- Linux在Enabling Swap Space处停留时间过长的解决过程
- 获取文件后缀名
- 启动一个进程,并让他等待接收消息
- 用PHP判断客户端浏览器类型自动做出后续判断
- ASP.NET"无法验证数据"的解决方法
- TP验证码使用小提示(已加入使用中文验证码的注意事项)
- VC6开发点滴
- JavaDB的基本使用