我正在尝试使用tile创建一个Spring MVC程序。
tiles.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="base.definition" template="/template/mainTemplate.jsp">
<put-attribute name="title" value="Piranha"></put-attribute>
<put-attribute name="header" value="/template/header.jsp"></put-attribute>
<put-attribute name="content" value=""></put-attribute>
<put-attribute name="footer" value="/template/footer.jsp"></put-attribute>
</definition>
<definition name="index" extends="base.defnition">
<put-attribute name="content" value="/view/index.jsp"></put-attribute>
</definition>
<definition name="searched" extends="base.definition">
<put-attribute name="content" value="/view/searched.jsp"></put-attribute>
</definition>
</tiles-definitions>
当我访问此网址http://localhost:8080/myProject/search
时,我收到此错误
错误
message Could not resolve view with name 'searched' in servlet with name 'welcome'
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Could not resolve view with name 'searched' in servlet with name 'welcome'
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1227)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
当我从tiles.xml中删除此代码时,它可以正常工作
<definition name="index" extends="base.defnition">
<put-attribute name="content" value="/view/index.jsp"></put-attribute>
</definition>
tiles.xml
档有什么问题?
答案 0 :(得分:1)
搞定了
这是一个简单的错字
您已撰写base.defnition
将其更改为base.definition
以下更正的代码。
<definition name="index" extends="base.definition">
<put-attribute name="content" value="/view/index.jsp"></put-attribute>
</definition>