1. 支持APP&API模式的RESTful配置示例
XML示例:
xmlns:context=http://www.springframework.org/schema/context
… default-autowire="byName"   >
           
           
                   
 
   
           
           
           
                                   
                                               
                                               
                                   
                       
                       
                       
                                   
                                   
                                       
                                           
                                           
                                           
                                       
                                   
                       
                       
           
           
           
           
           
              
                   
这是很重要的列装器, 可以方便地实现bean<=>xml, 需另外下载(http://xstream.codehaus.org/download.html),可比JAXB套件易用哦 -- >
                
           
           
 
2. 支持API模式的RESTful配置特例
Spring 3 Servlet + HttpMessageConverter + Annotation
        StringHttpMessageConverter:  Text converter
        FormHttpMessageConverter : Form converter (application/x-www-form-urlencoded , ampped to MultiValueMap)
        MarshallingHttpMessageConverter: XML converter(marshaller)
        MappingJacksonHttpMessageConverter: JSON converter(via Jackson ’s ObjectMapper
        AtomFeedHttpMessageConverter: ATOM converter(via ROME ’s Feed API)
        RssChannelHttpMessageConverter : RSS converter(via ROME ’s Feed API)
XML示例:
<
/bean>
 
com.company.project.bean.EntityA
com.company.project.bean.EntityB
控制器代码示例:
@RequestMapping(method=RequestMethod.GET, value="/emp/{id}", headers="Accept=application/json")
public @ResponseBody EntityA getEntityA(@PathVariable String id) { … return EntityA;}
 
2. 支持APP模式的RESTful配置特例
 
Spring 3 Servlet + MVC + Annotation
        ContentNegotiatingViewResolver:  Resource representation negotiation
        BeanNameViewResolver: Common view resolver based on bean name as spring-like.
        UrlBasedViewResolver:  Spring MVC view same as former Spring version (JSP for text/html)
        InternalResourceViewResolver: Mostly like to UrlBasedViewResolver.
        MappingJacksonJsonView : JSON view
        MarshallingView : XML view (via XStreamMarshaller or Jaxb2Marshaller, etc)
XML配置示例:
    xmlns:p= http://www.springframework.org/schema/p     xmlns:context="http://www.springframework.org/schema/context”   … default-autowire="byName"  
                       
           
       
      
           
                       
                       
                                   
                                               
                                               
                                               
                                   
                       
 
                                   
                                       
                                       
                                           
                                           
                                       
                                   
 
                                   
                                   
                                   
                                      
                                               
  
                                   
                                   
   
 
控制器代码示例:
@PATH(“/{id}”)
public ModelAndView show(@PathVariable java.lang.Integer id) throws Exception {
                        UserInfo userInfo = manger.get(id);
                        return new ModelAndView("/userinfo/edit","userInfo",userInfo);