Announcement Announcement Module
Collapse
No announcement yet.
web.xml servlet mapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • web.xml servlet mapping

    Hi,

    i want to map "all" requests to my spring-servlet so i chose

    Code:
        <servlet-mapping>
            <servlet-name>spring-servlet</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    That url pattern.

    The problem is:
    It seems the "default" servlet to which all "*.jsp" requests should be mapped is overridden because when a controller returns a jsp view i get:
    Code:
    No mapping for [/context-name/foobar.jsp] in DispatcherServlet with name 'spring-servlet'
    Last edited by Lori; Oct 30th, 2007, 11:07 AM.

  • #2
    Lori,

    What is the actual name of your servlet? For example, if my servlet is named 'spring', I would have an xml file named 'spring-servlet.xml'. I think that the issue may be that the servlet-name in the servlet-mapping should just be 'spring'.

    Good luck,

    Steve O

    Comment


    • #3
      Hey Steve O,

      thanks for your reply!
      But you can name your servlet as you like and configure it with an init-param where you name your config xml file:

      Code:
              <init-param>
                  <param-name>contextConfigLocation</param-name>
                  <param-value>
                  /WEB-INF/spring/applicationContext*.xml
                  /WEB-INF/spring/application*.xml
                 ...more
      Otherwise you would not be able to use more than one context config.

      I do not think that this is the problem.

      I did not want to make my inital question more complicated but what i now use as a workaround is this mapping which works with jsps:
      Code:
          <servlet-mapping>
              <servlet-name>spring-servlet</servlet-name>
              <url-pattern>/subfolder/*</url-pattern>
          </servlet-mapping>
      But now all requests must have that subfolder as prefix to the actual url which is not what i desire.

      Comment


      • #4
        Sorry, i need to push this.
        I would really love to get a suggestion.

        Comment


        • #5
          Originally posted by Lori View Post
          It seems the "default" servlet to which all "*.jsp" requests should be mapped is overridden because when a controller returns a jsp view i get:
          Code:
          No mapping for [/context-name/foobar.jsp] in DispatcherServlet with name 'spring-servlet'
          Well judging from the error it seems that "spring-servlet" is handling "/context-name/foobar.jsp" URL just fine (meaning your web.xml is ok), but your spring config is lacking url mapping for "/foobar.jsp".
          - Have you mapped this url to some controller?
          - Does this controller fire when you call this url?
          OR
          - Do you even want spring to handle *.jsp URLs, or want servlet container to handle them directly?

          Regards,
          Igor.

          Comment


          • #6
            Ah, you are right!
            There was one hole in my thoughts

            Well judging from the error it seems that "spring-servlet" is handling "/context-name/foobar.jsp" URL just fine (meaning your web.xml is ok), but your spring config is lacking url mapping for "/foobar.jsp".
            Absolutely (i made a mistake while thinking this over).

            - Have you mapped this url to some controller?
            - Does this controller fire when you call this url?
            No, of course not.

            - Do you even want spring to handle *.jsp URLs, or want servlet container to handle them directly?
            I want the default servlet to handle all *.jsp requests.
            But still i want all other requests handled by the spring-servlet.

            Comment


            • #7
              I would suggest using a particular url pattern like *.do instead of using *. Of course, you can always map your JSPs, but u will get into a mess when you have images to display. When u use *, even image requests will be mapped to DispatcherServlet, which u dont want to handle.

              Comment

              Working...
              X