我將用Spring 4和Apache Tiles 3設置一個新項目。我有一個奇怪的問題。Spring 4 + Apache Tiles 3顯示純文本
當我的瓷磚定義被加載,而不是顯示請求的JSP,控制器返回到瀏覽器的純文本沒有呈現。
view.xml用
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
</bean>
<bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer" id="tilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/tiles-definitions.xml</value>
</list>
</property>
</bean>
磚,definition.xml
<tiles-definitions>
<definition name="welcome" template="/WEB-INF/view/jsp/template.jsp" >
<put-attribute name="header" value="Test" />
<put-attribute name="body" value="Test" />
<put-attribute name="footer" value="Test" />
</definition>
template.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="header"><tiles:insertAttribute name="header"/></div>
<div id="body"><tiles:insertAttribute name="body"/></div>
<div id="footer"><tiles:insertAttribute name="footer"/></div>
</body>
</html>
春天登錄請求
17:23:55.637 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'applicationServlet' processing GET request for [/eurostart/]
17:23:55.637 [http-bio-8080-exec-8] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path/
17:23:55.637 [http-bio-8080-exec-8] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public java.lang.String it.insiel.eurostart.controller.WelcomeController.home()]
17:23:55.638 [http-bio-8080-exec-8] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'welcomeController'
17:23:55.638 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/eurostart/] is: -1
17:23:55.639 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.tiles3.TilesView: name 'welcome'; URL [welcome]] in DispatcherServlet with name 'applicationServlet'
17:23:55.639 [http-bio-8080-exec-8] DEBUG o.a.tiles.impl.BasicTilesContainer - Render request received for definition 'welcome'
17:23:55.640 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'applicationServlet' processing GET request for [/eurostart/WEB-INF/view/jsp/template.jsp]
17:23:55.640 [http-bio-8080-exec-8] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /WEB-INF/view/jsp/template.jsp
17:23:55.640 [http-bio-8080-exec-8] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/WEB-INF/view/jsp/template.jsp]
17:23:55.641 [http-bio-8080-exec-8] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Matching patterns for request [/WEB-INF/view/jsp/template.jsp] are [/**]
17:23:55.641 [http-bio-8080-exec-8] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - URI Template variables for request [/WEB-INF/view/jsp/template.jsp] are {}
17:23:55.641 [http-bio-8080-exec-8] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/WEB-INF/view/jsp/template.jsp] to HandlerExecutionChain with handler [org.spring[email protected]5f37e070] and 1 interceptor
17:23:55.641 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/eurostart/WEB-INF/view/jsp/template.jsp] is: -1
17:23:55.642 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'applicationServlet': assuming HandlerAdapter completed request handling
17:23:55.642 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
17:23:55.643 [http-bio-8080-exec-8] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
感謝所有誰幫我。
如果這是答案,那麼你應該標記它。 – Rembo