我有一个 jsp 看看。
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<div class="container-fluid">
<div class="logo row-fluid">
<div class="span12">
<img src="<c:url value="/img/logo.png"/>" />
</div>
</div>
<div class="row-fluid">
<div class="span6">
<form>
<fieldset>
<legend></legend>
</fieldset>
</form>
</div>
<div class="span6">
<form>
<fieldset>
<legend><spring:message code="home.form.legend.local"/></legend>
</fieldset>
</form>
</div>
</div>
</div>
<spring:message />
标记 jsp 被此消息破坏:org.springframework.web.util.NestedServletException :请求处理失败;嵌套异常是 org.apache.tiles.request.render.CannotRenderException: ServletException,包括路径“/WEB-INF/jsp/public_layout.jsp”。
如果删除<spring:message />
标签运行没有问题。
xxx-servlet.xml 配置:
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
瓷砖.xml:
<tiles-definitions>
<definition name="public.layout" template="/WEB-INF/jsp/public_layout.jsp">
<put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
</definition>
<definition name="home" extends="public.layout">
<put-attribute name="body" value="/WEB-INF/jsp/home.jsp" />
</definition>
</tiles-definitions>
public_layout.jsp:
<%@taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<tiles:insertAttribute name="header" />
<tiles:insertAttribute name="body" />
<tiles:insertAttribute name="footer" />
控制器:
@RequestMapping({"/", "/index"})
public String showHome() {
return "home";
}