About spring's problem with velocity (getting request,session)

Source: Internet
Author: User

The spring framework is being studied recently, using spring MVC. Shows using velocity to find a related document as a reference


Some properties of the view parser
<bean id= "Viewresolver"
class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name= "Exposespringmacrohelpers" value= "true"/>
<property name= "Requestcontextattribute" value= "RC"/>
<property name= "Viewclass" value= "Org.springframework.web.servlet.view.JstlView"/>
<property name= "prefix" value= "/"/>
<property name= "suffix" value= ". jsp"/>
</bean>

In the definition of the view parser, the "exposespringmacrohelpers" setting exposes a RequestContext (named Springbindrequestcontext) to external use through spring's macro library. The default value is False. It exposes macro actions for processing forms and validating error messages;

"Requestcontextattribute" exposes spring's RequestContext object to variable RC. Use ${rc.contextpath} to get the application's ContextPath (that is,/myusers); Read user.name with ${rc.getmessage ("/web-inf/classes/")} Messages.properties localized information. This object is essential for view technologies that do not access serlvet requests (i.e. velocity and freemarker templates).

There are also some properties:

Exposerequestattributes: Default value False to set whether all request properties are added to the model before merging with the template. (This can be understood as all objects contained within the request scope, not a real request object.) Exposesessionattributes: Default value False to set whether all session properties are added to model before merging with the template. (See IBID.)

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.