타일 통합을 사용하여 Struts2 f/w를 배우려고하지만 putAttributeTag에서 NPE를 구현 중입니다.타일을 호출 할 때 putAttribute의 NPE
로그인을 클릭하면 홈 페이지로 이동해야하지만 홈 페이지를 여는 동안 예외가 발생합니다.
다음은 관련 코드 중 일부입니다.
struts.xml
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"></result-type>
</result-types>
<action name="signin" class="actions.SigninAction" method="execute">
<result name="success" type="tiles">home</result>
</action>
</package>
tiles.xml
<tiles-definitions>
<definition name="baseLayout" template="/baseLayout.jsp">
<put-attribute name="title" value=""></put-attribute>
<put-attribute name="header" value="/header.jsp"></put-attribute>
<put-attribute name="leftmenu" value="/leftmenu.jsp"></put-attribute>
<put-attribute name="footer" value="/footer.jsp"></put-attribute>
<put-attribute name="rightmenu" value="/rightmenu.jsp"></put-attribute>
<put-attribute name="content" value=""></put-attribute>
</definition>
<definition name="home" extends="baseLayout">
<put-attribute name="content" value="/home.jsp"></put-attribute>
<put-attribute name="title" value="Home"></put-attribute>
</definition>
</tiles-definitions>
기본 레이아웃에 (템플릿의 다른 부분에 대한 다른 div의도 정의되어 있지만,이 난 것입니다 필요하다면 내가, 여기에 포함되지 않은 업데이트 baselayout)
<title><tiles:insertAttribute name="title" ignore="true"></tiles:insertAttribute>
</title>
</head>
<body>
<div id="leftmenu" class=".leftmenu">
<b>Add New</b><br> Update<br> Search<br> Remove
</div>
<div id="content" class=".content">
<tiles:putAttribute name="content"></tiles:putAttribute>
</div>
에는 간단한 한 줄 tex t 만. actions.SigninAction
은 success
만 반환합니다 (입력 유효성 검사는 아직 통합되지 않았습니다.이 액션도 성공을 반환합니다).
로그
메시지 :
ServletException including path '/baseLayout.jsp'.
ServletException including path '/baseLayout.jsp'.
스택 트레이스
org.apache.tiles.TilesException: ServletException including path '/baseLayout.jsp'.
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:614)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:246)
org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105)
및
org.apache.tiles.util.TilesIOException: ServletException including path '/baseLayout.jsp'.
org.apache.tiles.servlet.context.ServletTilesRequestContext.wrapServletException(ServletTilesRequestContext.java:298)
org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:200)
org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:179)
org.apache.tiles.context.TilesRequestContextWrapper.dispatch(TilesRequestContextWrapper.java:72)
및
java.lang.NullPointerException
org.apache.tiles.jsp.taglib.PutAttributeTag.execute(PutAttributeTag.java:204)
org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagSupport.java:75)
org.apache.jsp.baseLayout_jsp._jspx_meth_tiles_005fputAttribute_005f0(baseLayout_jsp.java:188)
org.apache.jsp.baseLayout_jsp._jspService(baseLayout_jsp.java:129)
내 실수를 지적하면 좋을 것입니다.
몇 가지 사항을 변경하여 문제를 해결했습니다. 내가 겪었던 n 개의 실수가있었습니다. – guptakvgaurav