標籤:
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value="/WEB-INF/jsp/" />
- <property name="suffix" value=".jsp" />
- </bean>
其實InternalResourceViewResolver的工作很簡單: 在視圖邏輯名前面加上prefix,後面加上suffix;
- <bean id="myViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
- <property name="order" value="1"/>
- <property name="basename" value="views"/>
- </bean>
因為可以配置多個viewResolver,所以上面的resolver還有一個選項order, 標明優先順序。
通過controller和直接存取jsp兩種
我希望把使用者可以直接存取的jsp放在 /jsp/ 下,把通過Controller才能訪問的jsp放在/WEB-INF/jsp/下
Spring mvc 使用多種viewResolver的問題
<bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath" value="/WEB-INF/velo/"/> <property name= "velocityProperties"> <props> <prop key="input.encoding">utf-8</prop> <prop key="output.encoding">utf-8</prop> </props> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="cache" value="false"/> <property name="prefix" value=""/> <property name="suffix" value=".vm"/> <property name="contentType"><value>text/html;charset=UTF-8</value></property> <property name="exposeSpringMacroHelpers" value="true"/> <property name="order"><value>0</value></property> </bean> <bean id="JSPviewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="cache" value="false"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> <property name="contentType"><value>text/html;charset=UTF-8</value></property> <property name="order"><value>1</value></property> </bean>
【viewResolver】 springmvc jsp