在处理Spring MVC和Apache tile时遇到此错误

时间:2016-06-03 11:22:27

标签: spring jsp spring-mvc apache-tiles

我不确定错误在哪里。

  

消息

Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException:
    org.apache.tiles.util.TilesIOException: 
        JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.

说明服务器遇到内部错误,导致无法完成此请求。

  

例外

org.springframework.web.util.NestedServletException:
    Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException:
        org.apache.tiles.util.TilesIOException: JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
  

根本原因

org.apache.tiles.impl.CannotRenderException: org.apache.tiles.util.TilesIOException:
    JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
    org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:692)
    org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
    org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
    org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
    org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
    org.springframework.js.ajax.tiles2.AjaxTilesView.renderMergedOutputModel(AjaxTilesView.java:131)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

tiles.xml定义如下

<tiles-definitions>
    <definition name="enterBookingInfo" extends="standardLayout">
        <put-attribute name="body" value="/WEB-INF/views/hotels/enterBookingInfo.jsp"> </put-attribute>
    </definition>
</tiles-definitions>

Tiles配置提取

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

1 个答案:

答案 0 :(得分:0)

我通过将表单的commandName属性设置为控制器中使用的modelAttribute对象的名称来解决此问题。

我还必须修改方法语法以使BindingResult参数必须遵循ModelAttribute对象。

public String ultimateBooking(@RequestParam("hotelId") String hotelId,@ModelAttribute("booking") Booking bookingValidation,BindingResult result,ModelMap model)

没有对tile.xml进行任何更改