springmvc InternalResourceViewResolver 匹配WEB-INF下的jsp和html页面
crazywind 提问于:2018-06-21
0 0

现在配置

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/ui/" ></property>
        <property name="suffix" value=".jsp" ></property>
</bean>

那么这些请求会匹配jsp,我还想匹配WEB-INF下的html页面怎么办?

  • 所有回答
emptycity 回答于:2018-06-22
1 0
<!-- viewResolver  suffix 填空 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/ui/" />
        <property name="suffix" value="" />
    </bean>

controller

@RequestMapping("/htmlView")
public String renderHtmlView() {
    return "index.html";
}

@RequestMapping("/jspView")
public String renderJspView() {
    return "index.jsp";
}

https://stackoverflow.com/questions/20564336/internalresourceviewresolver-to-resolve-both-jsp-and-html-together

我来回答    springmvc InternalResourceViewResolver 匹配WEB-INF下的jsp和html页面