struts2.2 json配置

转至:http://maxrocray.iteye.com/blog/1142438

很久没有做web了,温习下struts2的json配置。

所需Jar包如下:注意加上javassist.jar,OGNL依赖它。



Web.xml配置:

Java代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app version="2.5"   
  3.     xmlns="http://java.sun.com/xml/ns/javaee"   
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  5.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
  6.     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  
  7.     <filter>  
  8.         <filter-name>struts2</filter-name>  
  9.         <filter-class>  
  10.             org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter  
  11.         </filter-class>  
  12.     </filter>  
  13.   
  14.     <filter-mapping>  
  15.         <filter-name>struts2</filter-name>  
  16.         <url-pattern>/*</url-pattern>  
  17.     </filter-mapping>  
  18. </web-app>  


struts.xml配置: (extends="json-default")

Java代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE struts PUBLIC  
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  4.     "http://struts.apache.org/dtds/struts-2.0.dtd">  
  5.   
  6. <struts>  
  7.   <package name="test" extends="json-default">  
  8.     <action name="test" class="com.aimee.json.TestJsonAction" method="check">  
  9.         <result type="json">  
  10.         <!-- 不包含flag属性 -->  
  11.         <param name="excludeProperties">   
  12.             flag   
  13.         </param>  
  14.         </result>  
  15.     </action>  
  16.   </package>  
  17.   
  18. </struts>  



转载于:https://www.cnblogs.com/JPAORM/archive/2012/03/23/2510229.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值