<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="order" value="3" />
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="htmlviewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="2" />
<property name="prefix" value="/"></property>
<property name="suffix" value=".HTML"></property>
<property name="contentType" value="text/html;charset=UTF-8"></property>
</bean>
罪魁祸首 就是spring实现该方法时返回true,这样相当于view总是存在,从而导致其余视图解析器无法得到解析机会。
public boolean checkResource(Locale locale) throws Exception {
return true;
}
覆盖该方法,应该就可以了
public class IcomJstlView extends JstlView {
public boolean checkResource(Locale locale) throws Exception {
File file = new File(this.getServletContext().getRealPath("/")+getUrl());
return file.exists();//判断该jsp页面是否存在
}
}
或者order优先使用.HTML
来源:http://www.iteye.com/problems/76107