gpt4 book ai didi

java - org.apache.tiles.template.NoSuchAttributeException : Attribute 'body' not found

转载 作者:行者123 更新时间:2023-12-01 09:33:01 25 4
gpt4 key购买 nike

-我的堆栈跟踪

org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.
org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:49)
org.apache.tiles.template.InsertAttributeModel.resolveAttribute(InsertAttributeModel.java:187)
org.apache.tiles.template.InsertAttributeModel.start(InsertAttributeModel.java:107)
org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:306)
org.apache.jsp.WEB_002dINF.pages.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f1(layout_jsp.java:142)
org.apache.jsp.WEB_002dINF.pages.layout_jsp._jspService(layout_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1243)
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:968)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)

**Note** The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.

home.jsp 包含:

<!DOCTYPE html>
<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<head>
<%-- <title><tiles:getAsString name="title" /></title> --%>
</head>

<body>
<tiles:insertAttribute name="body" />

</body>
</html>

我正在尝试在 Spring 应用程序中添加图 block ,但收到org.apache.tiles.template.NoSuchAttributeException:找不到属性“body”

下面我提到了我的 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_2_1.dtd">
<tiles-definitions>
<!-- definition name="base.definition"
template="/WEB-INF/layouts/classic.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/basefragments/header.jsp" />
<put-attribute name="body" value="/WEB-INF/pages/home.jsp" />

</definition> -->
<!-- Home Page -->
<definition name="base.definition" template="/WEB-INF/pages/temp.jsp" >
<put-attribute name="title" value="Home Page" />
<put-attribute name="body" value="/WEB-INF/pages/home.jsp" />
</definition>
</tiles-definitions>

最佳答案

希望这对您有帮助,

在你的tiles.xml中

<tiles-definitions>
<definition name="base.definitions" template="/WEB-INF/layouts/classic.jsp">
<put-attribute name="title" value=""/>
<put-attribute name="header" value="/WEB-INF/basefragments/header.jsp"/>
<put-attribute name="body" value="/WEB-INF/pages/home.jsp" />
<put-attribute name="body" value=""/>
<put-attribute name="footer" value="/WEB-INF/page/footer.jsp"/>
</definition>

<definition name="/login" extends="base.definitions">
<put-attribute name="title" value="Contact Manager" />
<put-attribute name="body" value="/WEB-INF/pages/home.jsp" />
<put-attribute name="footer" value="/WEB-INF/pages/error.jsp" />
</definition>

哪里name="/login"是 url 模式(容器使用一个简单的过程将请求中的 URLweb.xml 中的 url 模式进行匹配)你想在 Spring 中映射 @Controller

像这样

@Controller
public class Test{

@RequestMapping(value = "/login",method = RequestMethod.GET)
public String loginPage(){
return "/login";
}
}

为您的<title>

<tiles:insertAttribute name="title" ignore="true" />

关于java - org.apache.tiles.template.NoSuchAttributeException : Attribute 'body' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39241871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com