struts集成restful
来源:互联网 发布:淘宝发布图片规则 编辑:程序博客网 时间:2024/06/07 01:21
参考网址:
http://blog.csdn.net/wangli61289/article/details/36662713
1、引入需要的JAR包
<!-- struts2依赖包 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.14</version>
</dependency>
<!-- struts restful 依赖包 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.14</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-rest-plugin</artifactId>
<version>2.3.14</version>
</dependency>
2、修改struts.xml配置文件
<struts>
<constant name="struts.i18n.reload" value="false" />
<constant name="struts.devMode" value="false" />
<!-- struts2 restful -->
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
<include file="struts-default.xml" />
</struts>
3、修改web.xml配置文件
<web-app>
<display-name>Archetype Created Web Application</display-name>
<init-param>
<param-name>config</param-name>
<!-- <param-value>../../resources/struts.xml</param-value> -->
<param-value>classpath:struts.xml</param-value>
</init-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- log4j -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/log4j.properties</param-value>
</context-param>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
4、编写Controller
Controller上面使用如下注解
@Results({
@Result(name="success", type="redirectAction", params = {"actionName" , "orders"})
})
5、编写JSP页面
JSP页面需要放到WEB-INF下面的content目录下,页面命名采用controller中的actionName+方法名;
如orders-index.jsp、orders-show.jsp
参考代码:
http://download.csdn.net/detail/hutudanvip/8394941
0 0
- struts集成restful
- STRUTS restful
- struts拓展restful
- dubbo 集成restful协议
- Struts 2 开发 RESTful 服务
- struts restful风格http接口
- CAS 之 集成RESTful API
- CAS4 之 集成RESTful API
- Struts(19)Struts集成
- Struts(19)Struts集成
- Struts + Velocity的集成
- Spring集成struts
- String,Struts,Hibernate集成
- Spring集成struts (1)
- Spring集成struts(2)
- Spring集成struts(3)
- spring struts hibernate 集成
- Stecks集成Struts (一)
- UVa 10935 - Throwing cards away I
- 杂记asla-lib库函数snd_pcm_open打开流程
- Vivado开发工具熟悉之IP Intergrator(Generate Block Design)
- 【poj 3056】The Bavarian Beer Party (区间DP+最大匹配不交叉的简单算法)
- php文件之间相互引用路径问题的一般处理方法
- struts集成restful
- Device namespace简介 - 基于Kernel namespace的设备虚拟化
- 关于CPoint的初始化与赋值
- 后缀数组(至少重复k次的可重叠的最长重复子串)—— POJ 3882
- u-boot.lds文件诠释
- Python mysql操作【转】
- 国外程序员整理的 C++ 资源大全
- 带给您灵感的25个最新鲜的 HTML5 网站
- VS2008编译C语言出错