Springmvc構成のmvc:annotation-driven
3569 ワード
springmvc構成を簡略化するためにspringは同時にmvc namespaceを導入し,構成した.
Springでは、a RequestMappingHandlerMapping、a RequestMappingHandler Adapter、and an ExceptionHandlerExceptionResolverの3つのbeanがデフォルトで登録され、注釈(@RequestMapping、@ExceptionHandler、@Controllerなど)で修飾されたcontroller処理要求をサポートします.また、次の機能もあります.
1、 Spring 3 style type conversion through a ConversionService instance in addition to the JavaBeans PropertyEditors used for Data Binding. 2、 Support for formatting Number fields using the @NumberFormat annotation through the ConversionService. 3、 Support for formatting Date, Calendar, Long, and Joda-Time fields using the @DateTimeFormat annotation. 4、 Support for validating @Controller inputs with @Valid, if a JSR-303 Provider is present on the classpath. 5、 HttpMessageConverter support for @RequestBody method parameters and @ResponseBody method return values from @RequestMapping or @ExceptionHandler methods.This is the complete list of HttpMessageConverters set up by mvc:annotation-driven:
構成例:
参照:1、springdoc 2、what's annotation-driven do
転載先:https://www.cnblogs.com/graph/p/8998697.html
Springでは、a RequestMappingHandlerMapping、a RequestMappingHandler Adapter、and an ExceptionHandlerExceptionResolverの3つのbeanがデフォルトで登録され、注釈(@RequestMapping、@ExceptionHandler、@Controllerなど)で修飾されたcontroller処理要求をサポートします.また、次の機能もあります.
1、 Spring 3 style type conversion through a ConversionService instance in addition to the JavaBeans PropertyEditors used for Data Binding. 2、 Support for formatting Number fields using the @NumberFormat annotation through the ConversionService. 3、 Support for formatting Date, Calendar, Long, and Joda-Time fields using the @DateTimeFormat annotation. 4、 Support for validating @Controller inputs with @Valid, if a JSR-303 Provider is present on the classpath. 5、 HttpMessageConverter support for @RequestBody method parameters and @ResponseBody method return values from @RequestMapping or @ExceptionHandler methods.This is the complete list of HttpMessageConverters set up by mvc:annotation-driven:
a. ByteArrayHttpMessageConverter converts byte arrays.
b. StringHttpMessageConverter converts strings.
c. ResourceHttpMessageConverter converts to/from org.springframework.core.io.Resource for all media types.
d. SourceHttpMessageConverter converts to/from a javax.xml.transform.Source.
e. FormHttpMessageConverter converts form data to/from a MultiValueMap.
f. Jaxb2RootElementHttpMessageConverter converts Java objects to/from XML — added if JAXB2 is present and Jackson 2 XML extension is not present on the classpath.
g. MappingJackson2HttpMessageConverter converts to/from JSON — added if Jackson 2 is present on the classpath.
h. MappingJackson2XmlHttpMessageConverter converts to/from XML — added if Jackson 2 XML extension is present on the classpath.
i. AtomFeedHttpMessageConverter converts Atom feeds — added if Rome is present on the classpath.
j. RssChannelHttpMessageConverter converts RSS feeds — added if Rome is present on the classpath.
構成例:
AllowSingleQuotes
QuoteFieldNames
WriteEnumUsingToString
WriteEnumUsingName
WriteNullNumberAsZero
SkipTransientField
WriteDateUseDateFormat
application/json;charset=UTF-8
text/html;charset=UTF-8
text/json;charset=UTF-8
参照:1、springdoc 2、what's annotation-driven do
転載先:https://www.cnblogs.com/graph/p/8998697.html