Results 1 to 3 of 3

Thread: Spring 2.5.2 recursive JSP

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Florianópolis, Brazil
    Posts
    57

    Default Spring 2.5.2 recursive JSP

    Greetings,

    I've just migrated from spring 2.0.8 to 2.5.2 and faced an unexpected problem.
    In my application, I have a JSP that references itself, a recursive page. I use it to create a tree menu. The userMenu.jsp starts the menu and in case new levels, the recursiveMenu.jsp is called.

    Here are their code
    userMenu.jsp
    Code:
    <%@ include file="/WEB-INF/athena/jsp/header.jsp" %>
    <div id="mainMenu" class="accordionMenu">
        <c:catch var="menuError">
            <c:forEach items="${model.menuTokens}" var="root">
                <c:if test="${not ud.permissions[root.token].invisible}">
                    <dl>
                        <dt><f:message key="${root.token}" /></dt>
                        <dd>
                            <c:forEach items="${root.childNodes}" var="child">
                                <c:set var="node" value="${child}" scope="request" />
                                <c:import url="/rm.atn" />
                            </c:forEach>
                        </dd>
                    </dl>
                </c:if>
            </c:forEach>
        </c:catch>
    </div>
    <c:if test="${not empty menuError}">${menuError}</c:if>
    recursiveMenu.jsp
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <%@ include file="/WEB-INF/athena/jsp/header.jsp" %>
    <c:if test="${not ud.permissions[node.token].invisible}">
        <c:catch var="exception">
            <c:if test="${node.actionToken}"></c:if>
        </c:catch>
        <c:choose>
            <c:when test="${not empty exception}">
                <div id="${node.token}" class="treeMenu">
                    <dl>
                        <dt><f:message key="${node.token}" /></dt>
                        <dd>
                            <c:forEach items="${node.childNodes}" var="child">
                                <c:set var="node" value="${child}" scope="request"/>
                                <c:import url="/rm.atn" />
                            </c:forEach>
                        </dd>
                    </dl>
                </div>
            </c:when>
            <c:otherwise>
                <a onclick="getMDIC().openWindow('${node.action.token}', false);"><f:message key="${node.action.word}" /></a><br />
            </c:otherwise>
        </c:choose>
    </c:if>
    servlet.xml
    Code:
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
            <property name="prefix" value="/WEB-INF/" />
            <property name="suffix" value="" />
        </bean>
        
        <bean id="urlMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
            <property name="order" value="1" />
        </bean> 
    
        <bean name="/userMenu.atn" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
            <property name="viewName" value="athena/jsp/userMenu.jsp"/>
        </bean>
    
        <bean name="/rm.atn" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
            <property name="viewName" value="athena/jsp/recursiveMenu.jsp" />
        </bean>
    'Til Spring 2.0.8, it all went well. But after the change, I started getting this message printed on my page instead of the menu:

    Code:
    javax.servlet.jsp.JspException: javax.servlet.jsp.JspException: Circular view path [/WEB-INF/athena/jsp/recursiveMenu.jsp]: already dispatched to this view path within the same request [/VisAct/WEB-INF/athena/jsp/main.jsp]. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
    I was going to post the stack trace, but got a "text too long" warning hehehe. If needed be, ask for it and I'll work something out.

    I read the 2.5.2 change log, and saw this:

    Quote Originally Posted by changelog
    * InternalResourceView detects circular dispatching to the same view even in case of pattern matches for same handler
    * InternalResourceView prevents dispatch to same handler path only if the "preventDispatchLoop" flag is set to "true"
    I'm not sure if this applies, but I don't exactly know what to do here.

    Any ideas?

    Cheers,

    Renato Back
    Last edited by renatopb; Mar 24th, 2008 at 07:08 AM. Reason: typos

  2. #2
    Join Date
    May 2008
    Posts
    1

    Default Spring 2.5.2 recursive JSP

    I'm facing the same problem (exactly the same problem, hehehe) and to fix it I did this:

    Code:
    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
            <property name="prefix" value="/WEB-INF/" />
            <property name="suffix" value="" />
    </bean>
    see you later!

  3. #3
    Join Date
    Jun 2008
    Posts
    17

    Default

    In my opinion - using "redirect:" is better. Use form backing object to retrieve the data you need for the page from a db. If the formBackingObject requires some parameters - pull them off the HttpRequest.
    When returning the model and view - add the http get parameters to the end.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •