springMVC实现多个前缀和后缀映射
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="view" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewNames" value="*jsp"> </property> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="view1" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewNames" value="*"> </property> <property name="prefix" value="/"/> <property name="suffix" value=".jsp"/> </bean> </beans>
其实就是通过viewNames判断,viewNames就是对ModelAndView穿过来的字符串进行正则判断,如果不符合就不进行执行。因此就可以实现多个映射器了。最后有一个需要用全匹配。
