복붙노트

[SPRING] 속성을 찾을 수 없습니다 : 봄과 타일에 NoSuchAttributeException

SPRING

속성을 찾을 수 없습니다 : 봄과 타일에 NoSuchAttributeException

나는이 사이트에서 묻는 모든 질문을 검색하고 모든 변화를 시도했지만 행운이 없었다. 따라서 여기에 검색어를 게시하십시오 :

다음과 같은 예외가 발생합니다.

HTTP Status 500 - org.apache.tiles.template.NoSuchAttributeException: Attribute 'body' not found.

type Exception report

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

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: org.apache.tiles.template.NoSuchAttributeException: Attribute 'body' not found.
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    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.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause

org.apache.tiles.template.NoSuchAttributeException: Attribute 'body' 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.views.home_jsp._jspx_meth_tiles_005finsertAttribute_005f0(home_jsp.java:146)
    org.apache.jsp.WEB_002dINF.views.home_jsp._jspService(home_jsp.java:79)
    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.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.
Apache Tomcat/7.0.35 

내 tiles.xml은 다음과 같습니다.

<tiles-definitions>
  <definition name="base.definition" template="/WEB-INF/views/home.jsp">
         <put-attribute name="body" value="/WEB-INF/views/menu.jsp" />
  </definition>
</tiles-definitions>

마지막으로 내 servlet-context.xml에는 다음과 같은 항목이 있습니다.

<beans:bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    </beans:bean>

    <!-- 
    <beans:bean id="viewResolver" 
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <beans:property name="viewClass">
        <beans:value>
            org.springframework.web.servlet.view.tiles2.TilesView
        </beans:value>
    </beans:property>
    </beans:bean>
 -->
    <beans:bean id="tilesConfigurer" 
    class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <beans:property name="definitions">
        <beans:list>
            <beans:value>/WEB-INF/tiles.xml</beans:value>
        </beans:list>
    </beans:property>
    </beans:bean>

이전에 게시 된 질문에서이 답을 시도했지만 동일한 문제가 발생했기 때문에 일부 의견이 있습니다.

내 POM.xml에는 다음과 같은 항목이 있습니다 (확실하게).

           <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>2.2.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-template</artifactId>
        <version>2.2.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>2.2.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-servlet</artifactId>
        <version>2.2.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

내 집에이 코드가 있습니다 .jsp as :

<tiles:insertAttribute name="body" />

그리고 내 menu.jsp는 다음과 같습니다.

<ul>
<li><a href="search.htm">Search</a></li>
<li><a href="showMessages.htm">Messages</a></li>
<li><a href="contacts.htm">My Contacts</a></li>
<li><a href="change.htm">Password</a></li>
<li><a href="logout.htm">Logout</a></li>
</ul>

도와주세요. 다른 것이 필요한 경우 요청하십시오. 미리 감사드립니다.

해결법

  1. ==============================

    1.tiles.xml에서 몇 가지 변경 사항을 찾은 후에 답을 찾았습니다.

    tiles.xml에서 몇 가지 변경 사항을 찾은 후에 답을 찾았습니다.

    주된 문제점은 정의를 직접 사용할 수 없다는 것입니다. 당신은 그것을 확장해야하고 그것을 사용할 수 있습니다.

    이 편집 코드를 참조하십시오.

    <definition name="new.definition" template="/WEB-INF/layout/newlayout.jsp"> 
    <put-attribute name="title" value="" /> 
    <put-attribute name="body" value="" /> 
    <put-attribute name="menu" value="" /> 
    </definition> 
    
    <definition name="choice" extends="new.definition"> 
    <put-attribute name="title" value="" /> 
    <put-attribute name="body" value="/WEB-INF/views/choice.jsp" /> 
    <put-attribute name="menu" value="" /> 
    <put-attribute name="right" value="" /> 
        </definition> 
    
    <definition name="logout" extends="new.definition"> 
    <put-attribute name="title" value="Logging out.." />
     <put-attribute name="body" value="/WEB-INF/views/logout.jsp" />
     <put-attribute name="menu" value="" /> 
    <put-attribute name="right" value="" /> 
    </definition> 
    

    보시다시피, 처음에 "new.definition"으로 새 정의를 작성한 다음 선택 및 로그 아웃을 위해 기존 정의를 확장했습니다.

  2. from https://stackoverflow.com/questions/15752519/attribute-not-foundnosuchattributeexception-in-tiles-with-spring by cc-by-sa and MIT license