??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲黑人嫩小videos,精品国产_亚洲人成在线,亚洲av麻豆aⅴ无码电影http://www.tkk7.com/stevenjohn/category/52315.html那些青春的岁?/description>zh-cnSat, 12 Jan 2013 21:35:00 GMTSat, 12 Jan 2013 21:35:00 GMT60SpringMVC与fastjson整合q同时解决中文ؕ码问?/title><link>http://www.tkk7.com/stevenjohn/archive/2013/01/12/394144.html</link><dc:creator>abin</dc:creator><author>abin</author><pubDate>Sat, 12 Jan 2013 15:56:00 GMT</pubDate><guid>http://www.tkk7.com/stevenjohn/archive/2013/01/12/394144.html</guid><wfw:comment>http://www.tkk7.com/stevenjohn/comments/394144.html</wfw:comment><comments>http://www.tkk7.com/stevenjohn/archive/2013/01/12/394144.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/stevenjohn/comments/commentRss/394144.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/stevenjohn/services/trackbacks/394144.html</trackback:ping><description><![CDATA[<div><span style="color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff;"> 今天试着把SpringMVC与fastjson整合了下Q经试也能解决json含中文ؕ码的问题Q特此分享之。我也是初用Q详l文请?/span><a target="_blank" style="padding: 0px; margin: 0px; color: #682702; text-decoration: initial; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff;">官网</a><span style="color: #2c2c2c; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff;">?/span><br />public class MappingFastJsonHttpMessageConverter extends <br />        AbstractHttpMessageConverter<Object> { <br />    public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); <br /> <br />    private SerializerFeature[] serializerFeature; <br /> <br />    public SerializerFeature[] getSerializerFeature() { <br />        return serializerFeature; <br />    } <br /> <br />    public void setSerializerFeature(SerializerFeature[] serializerFeature) { <br />        this.serializerFeature = serializerFeature; <br />    } <br /> <br />    public MappingFastJsonHttpMessageConverter() { <br />        super(new MediaType("application", "json", DEFAULT_CHARSET)); <br />    } <br /> <br />    @Override <br />    public boolean canRead(Class<?> clazz, MediaType mediaType) { <br />        return true; <br />    } <br /> <br />    @Override <br />    public boolean canWrite(Class<?> clazz, MediaType mediaType) { <br />        return true; <br />    } <br /> <br />    @Override <br />    protected boolean supports(Class<?> clazz) { <br />        throw new UnsupportedOperationException(); <br />    } <br /> <br />    @Override <br />    protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) <br />    throws IOException, HttpMessageNotReadableException { <br />        ByteArrayOutputStream baos = new ByteArrayOutputStream(); <br />        int i; <br />        while ((i = inputMessage.getBody().read()) != -1) { <br />            baos.write(i); <br />        } <br />        return JSON.parseArray(baos.toString(), clazz); <br />    } <br /> <br />    @Override <br />    protected void writeInternal(Object o, HttpOutputMessage outputMessage) <br />    throws IOException, HttpMessageNotWritableException { <br />        String jsonString = JSON.toJSONString(o, serializerFeature); <br />        OutputStream out = outputMessage.getBody(); <br />        out.write(jsonString.getBytes(DEFAULT_CHARSET)); <br />        out.flush(); <br />    } <br />} <br /><br /><br /><br /><span style="color: #2c2c2c; font-family: 'Courier New', monospace; font-size: 12px; line-height: 24px; white-space: pre; background-color: #f7f7f7;">SpringMVC关键配置Q?/span><div><mvc:annotation-driven> <br />    <mvc:message-converters register-defaults="true">        <br />        <!-- fastjosn spring support --> <br />        <bean id="jsonConverter" class="com.alibaba.fastjson.spring.support.MappingFastJsonHttpMessageConverter"> <br />            <property name="supportedMediaTypes" value="application/json" /> <br />            <property name="serializerFeature"> <br />                <list> <br />                    <value>WriteMapNullValue</value> <br />                    <value>QuoteFieldNames</value> <br />                </list> <br />            </property> <br />        </bean> <br />    </mvc:message-converters> <br /></mvc:annotation-driven> </div><br /><br /><div>http://xyly624.blog.51cto.com/842520/896704</div></div><img src ="http://www.tkk7.com/stevenjohn/aggbug/394144.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/stevenjohn/" target="_blank">abin</a> 2013-01-12 23:56 <a href="http://www.tkk7.com/stevenjohn/archive/2013/01/12/394144.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Gson 实例一http://www.tkk7.com/stevenjohn/archive/2012/07/31/384401.htmlabinabinTue, 31 Jul 2012 01:08:00 GMThttp://www.tkk7.com/stevenjohn/archive/2012/07/31/384401.htmlhttp://www.tkk7.com/stevenjohn/comments/384401.htmlhttp://www.tkk7.com/stevenjohn/archive/2012/07/31/384401.html#Feedback0http://www.tkk7.com/stevenjohn/comments/commentRss/384401.htmlhttp://www.tkk7.com/stevenjohn/services/trackbacks/384401.htmlpackage org.abin.lee.json;

public class Employee {
 private String name="abin";
 private double salary=1000;
 private String sex="M";
 
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public double getSalary() {
  return salary;
 }
 public void setSalary(double salary) {
  this.salary = salary;
 }
 public String getSex() {
  return sex;
 }
 public void setSex(String sex) {
  this.sex = sex;
 }
 

}







package org.abin.lee.json;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonTest {
 public static void main(String[] args) {
  GsonBuilder builder=new GsonBuilder();
  Gson gson=builder.create();
  String json1=gson.toJson(new Employee());
  System.out.println("json1="+json1);
  
  Employee json2=gson.fromJson(json1, Employee.class);
  System.out.println("json2="+json2);
  System.out.println(json2.getName());
  System.out.println(json2.getSalary());
  System.out.println(json2.getSex());
  System.out.println(json2.getClass());
  
  
 }

}



abin 2012-07-31 09:08 发表评论
]]>
վ֩ģ壺 fc2ѹƵվ| ӰԺavɫ| ׾Ʒһ | һAëƬѹۿþþƷ| Ʒþ޾þþþûʿ| ޹ۺϾƷĵһ| 鶹¹AVԭ| ˳ӰԺ߸| www.999ƷƵۿ| 97se޹ۺ| ҪWWWѿƵ| JLZZJLZZٸ| һѹۿ | Ժ޺Ժ߹ۿ| Ʒva鶹| ȫAһëƬ| պ߾Ʒһ| 㶮õ߹ۿƵ| 91avƵ| ߹ۿɫƬƵ| һ| ձ| պ뾫Ʒþһ| ޵Ӱѹۿ| AVƬ߲ | 3pˬִƵ| vaĻþ | պƵһ | 91Ʒȫѹۿ| þþ뾫ƷպĦ| Ļ벻Ƶ| ɫwwwƷƵѿ| avƷ| avѸ߳ˮ| ȫAһëƬ| 337pձŷ޴| ûվɫƵֱ| ߻ɫӰ| ŷղ| AVƷ鶹 | þWWW˳ɡƬ|