SpringMvc sitemesh freemarker integration summary, springmvcsitemesh

Source: Internet
Author: User

SpringMvc sitemesh freemarker integration summary, springmvcsitemesh
Preface

  • I personally like springmvc's perfect support for restful, coupled with simple configuration and natural integration with spring, so the project intends to use springMvc;
  • Freemarker has many evaluations on the Internet, but its performance is not crowded, but it is sufficient for the environment of our project. It is also very convenient to add its rich built-in functions and instructions;
  • As for sitemesh, simple configuration is sufficient for small and medium-sized projects;
Configuration

The configuration of web. xml is as follows:

<Context-param> <param-name> contextConfigLocation </param-name> <param-value> classpath: spring/applicationContext. xml </param-value> </context-param> <listener-class> org. springframework. web. context. contextLoaderListener </listener-class> </listener> <filter-name> encodingFilter </filter-name> <filter-class> org. springframework. web. filter. characterEncodingFilter </filter-class> <Sync-supported> true </async-supported> <init-param> <param-name> encoding </param-name> <param-value> UTF-8 </param-value> </init-param> <param-name> forceEncoding </param-name> <param-value> true </param-value> </init-param> </filter> <filter-name> sitemesh </filter-name> <filter-class> com. opensymphony. sitemesh. webapp. siteMeshFilter </filter-class> <async-supported> true </async-supported> </Filter> <! -- Encoding --> <filter-mapping> <filter-name> encodingFilter </filter-name> <url-pattern>/* </url-pattern> </filter-mapping> <! -Sitemesh -->
<Filter-mapping> <filter-name> sitemesh </filter-name> <url-pattern>/* </url-pattern> </filter-mapping> <! -Springmvc --> <servlet-name> springServlet </servlet-name> <servlet-class> org. springframework. web. servlet. dispatcherServlet </servlet-class> <init-param> <param-name> contextConfigLocation </param-name> <param-value> classpath: /spring/springMvc/spring_mvc_base.xml </param-value> </init-param> <load-on-startup> 1 </load-on-startup> </servlet> <! -Freemarker configuration -->
<Servlet> <servlet-name> sitemesh-freemarker </servlet-name> <servlet-class> com. opensymphony. module. sitemesh. freemarker. freemarkerDecoratorServlet </servlet-class> <init-param> <param-name> TemplatePath </param-name> <param-value>/</param-value> </init- param> <init-param> <param-name> default_encoding </param-name> <param-value> UTF-8 </param-value> </init-param> <load- on-startup> 2 </load-on-startup> </servl Et> <servlet-mapping> <servlet-name> springServlet </servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <! -Freemarker page configuration -->
    <servlet-mapping>        <servlet-name>sitemesh-freemarker</servlet-name>        <url-pattern>*.htm</url-pattern>    </servlet-mapping>

 

Spring mvc and spring configurations do not need to be discussed;

Here, there are two places;

 

Summary

Finally, you need to think more, debug more, and understand the problems you encounter.

 

 

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.