web front-end project integrates both JSP and FreeMaker_u_Multi-view Parser Configuration

*In 2017, at the request of the company, responsible for research and development of intelligent analysis platform, using OLAP technology to analyze tax data from multiple dimensions, levels and cross-business domains, discover data characteristics, summarize tax laws, and support leadership decision-making. After nearly a year, it was finally sorted out version 1.0. Now it is slightly summarized what was used in the whole development process, for one year in a row.More than 80% are working overtime, miserable!

The company's framework is called loushang2016, which is based on springMVC+mybatis and uses JSP for the front-end, but during the development process, I want to use FreeMaker and JSP to develop front-end pages compatible. Next, I will focus on how common WEB projects integrate FreeMaker without affecting the use of JSP. In mvc-Context.xmlConfigure a multi-view parser in.

<!-- Configure View Parser -->	
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/jsp/" />
		<property name="suffix" value=".jsp" />
		<property name="order" value="1" /> <!-- Matching order -->
	</bean>
	<!-- To configure freeMarker view resolver -->
    <bean id="viewResolverFtl" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
        <property name="contentType" value="text/html; charset=UTF-8"/>
        <property name="exposeRequestAttributes" value="true" />
        <property name="exposeSessionAttributes" value="true" />
        <property name="exposeSpringMacroHelpers" value="true" />
        <property name="cache" value="true" />
        <property name="suffix" value=".html" />
        <property name="order" value="0"/> <!-- order -->
    </bean>
       <!-- To configure freeMarker Template Path -->
    <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/html/"/>
        <property name="freemarkerVariables">
            <map>
                <entry key="xml_escape" value-ref="fmXmlEscape" />
            </map>
        </property>
        <property name="defaultEncoding" value="UTF-8"/>
        <property name="freemarkerSettings">
            <props>
                <prop key="template_update_delay">0</prop><!-- How often do templates update -->
                <prop key="locale">zh_CN</prop>
                <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
                <prop key="date_format">yyyy-MM-dd</prop>
                <prop key="number_format">#.##</prop>
            </props>
        </property>
    </bean>
    <bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape"/>
	<bean id="multipartResolver"		
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="defaultEncoding" value="UTF-8"></property>		
		<!-- Set a maximum file upload value of 5 MB,5*1024*1024 -->		
		<property name="maxUploadSize" value="52428800"></property>		
	</bean>

Keywords: FreeMarker JSP Mybatis

Added by xxxzom_biexxx on Wed, 08 Jul 2020 17:29:29 +0300