Configuration and action in spring and internationalization configuration

Source: Internet
Author: User
Tags aop json locale

<aop:aspectj-autoproxy/> Role

Weaving @aspectj Facets by configuration

Although the facets can be woven programmatically, in general, we use spring's configuration to automate the creation of the agent-woven facets.

The <aop:aspectj-autoproxy/> Declaration of the AOP namespace automatically creates an agent for those beans in the spring container that are configured with @aspectj facets, weaving the facets. Of course, spring is still internally using Annotationawareaspectjautoproxycreator for automatic proxy creation, but the specifics of the implementation have been <aop:aspectj-autoproxy/> It's hidden.

<aop:aspectj-autoproxy/> has a Proxy-target-class property that defaults to false, which means that the use of JDK dynamic agent weaving enhancements, when fitted with <aop:aspectj-autoproxy Poxy-target-class= "true"/> Represents the use of Cglib dynamic Agent technology to weave in the enhancement. However, even if the Proxy-target-class is set to False, if the target class does not declare an interface, spring will automatically use the Cglib dynamic proxy.

@AspectJ Grammar Basics

@AspectJ the facets are described using the jdk5.0 annotation and the tangent expression language of the regular AspectJ 5, because spring supports only the connection points of the method, spring supports only partial aspectj of the tangent language, and in this section, We will do the necessary learning for the aspectj tangent-point expression language.

<aop:aspectj-autoproxyproxy-target-class= "true"/>

<context:annotation-config/>

<context:component-scanbase-package= "com.wzh.**.**" ></context:component-scan>



in the Spring3.0

In this version of Spring3.0.5,<mvc:annotation-driven/> declaration is not defaultannotationhandlermapping this attribute, For @resultmapping label parsing, it is written dead must use "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" This class to deal with.

<mvc:annotation-driven/> Annotation Significance

<mvc:annotation-driven/> is a shorthand form that can be manually configured instead of this shorthand form, which allows beginners to quickly apply the default configuration scheme. <mvc:annotation-driven/> will automatically register defaultannotationhandlermapping and annotationmethodhandleradapter two beans, is required by spring MVC to distribute the request to @controllers.
and provides: Data binding support, @NumberFormatannotation support, @DateTimeFormat support, @Valid support, read/write XML support (JAXB), read/write JSON support (Jackson).
Later, we used the JSON support when we processed the response to the AJAX request.
Later, when you write JUnit unit tests on an action, you take defaultannotationhandlermapping and annotationmethodhandleradapter two beans from the spring IOC container, To complete the test, take the time to know is the <mvc:annotation-driven/> this sentence registered two beans.


Spring's internationalization configuration

The first type: Acceptheaderlocaleresolver

<bean id= "Localeresolver" class= "Org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver" > </ Bean>
The default parameter name is the locale idea case. What you put in there is your submission parameters. such as: EN_US,ZH_CN, this time, you add a sentence on the page <a href= "? locale=zh_cn" > Simplified Chinese </a>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.