乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Spring MVC的自動(dòng)轉(zhuǎn)換功能 HttpMessageConverter

       老鼠愛(ài)上美貓 2012-08-09
      默認(rèn)起用的MVC注解功能
      <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">

      StringHttpMessageConverter: that can read and write Strings from the HTTP request and response.

      FormHttpMessageConverter:that can read and write form data from the HTTP request and response.

      ByteArrayMessageConverter:that can read and write byte arrays from the HTTP request and response.

      MarshallingHttpMessageConverter:XML的轉(zhuǎn)換需要使用Spring的 Marshaller 和 Unmarshaller.

      MappingJacksonHttpMessageConverter:JSON的轉(zhuǎn)換.

      SourceHttpMessageConverter:能夠讀/寫(xiě)來(lái)自HTTP的請(qǐng)求與響應(yīng)的javax.xml.transform.Source ,支持DOMSourceSAXSource, 和 StreamSource 的XML格式

      BufferedImageHttpMessageConverter:that can read and write java.awt.image.BufferedImage from the HTTP request and response

      起用JSON轉(zhuǎn)換功能
      xml
       1     <!-- 啟動(dòng)Spring MVC的注解功能,完成請(qǐng)求和注解POJO的映射 -->
       2     <bean
       3         class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
       4         <property name="messageConverters">
       5             <util:list id="beanList">
       6                 <ref bean="stringHttpMessageConverter" />
       7                 <ref bean="jsonHttpMessageConverter" />
       8                 <ref bean="marshallingHttpMessageConverter" />
       9             </util:list>
      10         </property>
      11     </bean>
      12 
      13     <bean id="stringHttpMessageConverter"
      14         class="org.springframework.http.converter.StringHttpMessageConverter" />
      15     <bean id="jsonHttpMessageConverter"
      16         class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
      17     <bean id="marshallingHttpMessageConverter"
      18         class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
      19         <property name="marshaller" ref="castorMarshaller" />
      20         <property name="unmarshaller" ref="castorMarshaller" />
      21     </bean>
      22 
      23     <bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller" />
      24 

      MappingJacksonHttpMessageConverter能夠?qū)OJO對(duì)象自動(dòng)轉(zhuǎn)換為JSON對(duì)象

          @RequestMapping(value = "/getPojoJson" , method=RequestMethod.GET)
          
      public @ResponseBody Pojo getPojoJson() {
            Pojo pojo
      =new Pojo();
            pojo.setA(
      "test");
            pojo.setB(
      1);
            pojo.setD(
      new Date());
            
      return pojo;
          }
      需要依賴(lài)JSON對(duì)象的處理JAR包
      jackson-core-lgpl.jar
      jackson-mapper-lgpl.jar
      下載地址:
      http://jackson./

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類(lèi)似文章