spring配置注解同时启用@ResponseBody,@RequestBody 注解实现实体与json转换


?xml version= "1.0"  encoding= "UTF-8" ? beans xmlns= "http://www.springframework.org/schema/beans" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:context= "http://www.springframework.org/schema/context" xmlns:mvc= "http://www.springframework.org/schema/mvc" xsi:schemaLocation="http: //www.springframework.org/schema/beans  http: //www.springframework.org/schema/beans/spring-beans.xsd http: //www.springframework.org/schema/context http: //www.springframework.org/schema/context/spring-context-4.0.xsd http: //www.springframework.org/schema/mvc http: //www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"   !-- 注解扫描包 -- context:component-scan base- package = "com.key"  / !-- AOP式方法级权限检查 -- bean class = "org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on= "lifecycleBeanPostProcessor" property name= "proxyTargetClass"  value= "true" / /bean   !-- 开启Shiro注解的Spring配置方式的beans。在lifecycleBeanPostProcessor之后运行 --                bean  class = "org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"   property name= "securityManager"  ref= "securityManager" /bean     !-- 静态资源(js/image/css)的访问 -- mvc:resources location= "/"  mapping= "/*/**" !-- 定义视图解析器 -- bean id= "viewResolver"  class = "org.springframework.web.servlet.view.InternalResourceViewResolver" property name= "prefix"  value= "/" /property property name= "suffix"  value= ".jsp" /property /bean   !-- 注解 @RequestBody 接收json同时转化为实体的配置 --   bean id= "mappingJacksonHttpMessageConverter"            class = "org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"  property name= "objectMapper" bean  class = "org.codehaus.jackson.map.ObjectMapper" property name= "dateFormat" bean  class = "java.text.SimpleDateFormat" constructor-arg type= "java.lang.String"  value= "yyyy-MM-dd HH:mm:ss" /constructor-arg /bean /property /bean /property          /bean   bean  class = "org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"             property name= "messageConverters"                 list                    ref bean= "mappingJacksonHttpMessageConverter"  /                /list            /property        /bean      /beans
最新回复(0)
/jishub_2FxWb6tLBRyQch0AhScb6Q5iFOFQAZS2UFCUbdaVf30_3D4638782
8 简首页