Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3663624
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:33:05+00:00 2026-05-19T01:33:05+00:00

I’m creating a hello world spring project on glassfish 2.1. I’m trying to use

  • 0

I’m creating a hello world spring project on glassfish 2.1. I’m trying to use the SimpleUrlHandlerMapping to map everything that ends in /spring/*.htm to my spring controller. Here is what I have:

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
    <display-name>Test MVC Project</display-name>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

  <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/spring/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list> 
</web-app>

in my dispatcher-servlet.xml file:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="defaultController"
        class="org.springframework.web.servlet.mvc.ParameterizableViewController">
        <property name="viewName" value="WEB-INF/jsp/springbean-view.jsp" />
    </bean>

    <bean id="urlMapping"
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="*.htm">defaultController</prop>
            </props>
        </property>
    </bean>

</beans>

My sun-web.xml file:

<sun-web-app>
    <context-root>/foo</context-root>
    <class-loader delegate="false" />
</sun-web-app>

When I request http://localhost:9680/foo, I see the welcome page. When I request http://localhost:9680/foo/spring/test.htm, I get a 404.

I have tried many variations of patterns in the urlMapping in the servlet.xml file. The only thing I have gotten to work is if I do this:

<bean id="urlMapping"
    class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="/*">defaultController</prop>
        </props>
    </property>
</bean>

When I request http://localhost:9680/foo/spring, it works. To me, this means that my web.xml is correct because it is properly passing the request to the dispatch servlet. When I request http://localhost:9680/foo/spring/test.htm (or anything that ends in /spring/*, I get a 500 with this exception:

javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

I feel like I’m doing something very stupid, but after several hours of googling and playing around with the mappings, I’m stumped.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:33:06+00:00Added an answer on May 19, 2026 at 1:33 am

    This is almost correct:

    <prop key="/*">defaultController</prop>
    

    But that can be simpler still:

    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="defaultHandler" ref="defaultController"/>
    </bean>
    

    Also, the reason you’re getting the endless forwarding loop is this:

    <bean id="defaultController" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
        <property name="viewName" value="WEB-INF/jsp/springbean-view.jsp" />
    </bean>
    

    The problem here is there’s no leading / on the viewName, so it’s interpreted as relative. So, when you go to the URL ending /foo/spring/test.htm, the relative forward URI is /foo/spring/WEB-INF/jsp/springbean-view.jsp, which in turn is caught by the url-pattern in web.xml, so it goers back into the DispatcherServlet, which forwards it on, etc etc etc. Endless loop.

    Easy fix:

    <property name="viewName" value="/WEB-INF/jsp/springbean-view.jsp" />
    

    Note the leading /

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I am trying to loop through a bunch of documents I have to put
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.