Announcement Announcement Module
No announcement yet.
Tag <spring:url > works incorrectly when the application context path is / Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tag <spring:url > works incorrectly when the application context path is /

    Hello all!
    I'm developing a Web application based on Spring MVC framework with the following simplified structure:


    index.jsp is specified in web.xml in welcome-file-list.

    I need resolve the relative path for JS file on start.jsp and index.jsp regard to context path. For this purpose on my jsp I have used <spring:url> tag or <c:url/> with required parameters.

    1. When I have deployed my application in a folder: pageContext.request.contextPath returns "/glassmanager", on both jsp (index.jsp and start.jsp) <spring:url value="/js/jquery/jquery-1.7.1.min.js"/> returns
    "/glassmanager/js/jquery/jquery-1.7.1.min.js" as expected. All is fine.

    2. When I have deployed my application in the root: pageContext.request.contextPath returns "/" <spring:url value="/js/jquery/jquery-1.7.1.min.js"/> returns the following results:
    a) for index.jsp = /js/jquery/jquery-1.7.1.min.js as expected
    b) for start.jsp = //js/jquery/jquery-1.7.1.min.js with REDUNDANT slash

    Obviously, situation described in 2.b is incorrect and represents my problem.
    I haven't added a slash in my code anywhere.

    I'm not very experienced with Spring, but following the API docs I have any problem with other issues.
    Any ideas what can be wrong?
    Thanks a lot in advanced.

    P.S. I use spring 3
    Last edited by dmedvedev; Jan 24th, 2012, 01:50 PM.

  • #2
    What do you mean by "deployed my application in a folder" or "in the root"? Posting relevant web.xml snippets will help.


    • #3
      This question is not actual for me anymore. As I expected, it was my fault with ant target. My context file for tomcat was named by ant target to {empty_string}.xml instead of ROOT.xml as required. I change it and now all works correct.
      Thank you
      Last edited by dmedvedev; Jan 26th, 2012, 10:16 AM.