spring mvc project controller without direct access to html file configuration

1, using the velocity

pom added

        <!-- Velocity视图所需jar -->
        <dependency>
            <artifactId>velocity</artifactId>
            <groupId>org.apache.velocity</groupId>
            <version>1.7</version>
        </dependency>

spring-mvc.xml configure resource loading path

   <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath" value="/WEB-INF/page/"/>
        <property name="velocityProperties">
            <props>
                <prop key="input.encoding">UTF-8</prop>
                <prop key="output.encoding">UTF-8</prop>
                <prop key="contentType">text/html;charset=UTF-8</prop>
            </props>
        </property>
    </bean>

The following html which can be accessed using ../demoShop/order.html: 

2, in the click spring-servlet configuration, the most simple mvc: resource tag is implemented manner in which his party.

<mvc:resources mapping="/shop/**" location="/page/" />

In this way, all files in the / page / folder when using url mode / shop / ** access, you can directly visit.

Guess you like

Origin blog.csdn.net/CaptainJava/article/details/90244022