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

  • SEARCH
  • Home
  • 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 584223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:52:31+00:00 2026-05-13T14:52:31+00:00

What I’m trying to do is map requests to the servlet root (correct terminology?).

  • 0

What I’m trying to do is map requests to the servlet root (correct terminology?). I’m at the point where URLs are mapped to correct view but all the static content – css, javascript, images – that is part of the page cannot be found.

So in my web.xml my servlet tag looks like this

<servlet-mapping>
    <servlet-name>springapp</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

My controller looks something like this:

@RequestMapping("/shop")
public class TheShopController extends MyBaseController {

    public static String VIEW = "Tile.Shop";

    @Override
    @RequestMapping(method = RequestMethod.GET)
    protected ModelAndView processRequest(HttpServletRequest req, HttpServletResponse resp) {
        ModelAndView mav = new ModelAndView(VIEW);
        return mav;
    }

}

MyBaseController is very simple. It looks like this:

public abstract class MyBaseController extends AbstractController {

    protected Logger log = Logger.getLogger(getClass());

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp) 
        throws Exception {

        ModelAndView mav = processRequest(req, resp);
        return mav;
    }

    protected abstract ModelAndView processRequest(HttpServletRequest req, HttpServletResponse resp);
}

I’m using Tiles in my view layer. My configuration is as follows:

/WEB-INF/tiles-defs.xml

As I mentioned, the views are found but the static resources that are a port of the page can’t be found. Here is some typical logging out put:

2010-01-24 17:25:01,777 DEBUG [http-8080-7] servlet.DispatcherServlet
(DispatcherServlet.java:690) – DispatcherServlet with name ‘springapp’
processing GET request for [/springapp/static/css/account.css]
2010-01-24 17:25:01,778 WARN [http-8080-4] servlet.DispatcherServlet
(DispatcherServlet.java:962) – No mapping found for HTTP request with
URI [/springapp/static/css/shop.css] in DispatcherServlet with name
‘springapp’ 2010-01-24 17:25:01,778 DEBUG [http-8080-6]
servlet.FrameworkServlet (FrameworkServlet.java:677) – Successfully
completed request 2010-01-24 17:25:01,778 WARN [http-8080-5]
servlet.DispatcherServlet (DispatcherServlet.java:962) – No mapping
found for HTTP request with URI [/springapp/static/css/offers.css] in
DispatcherServlet with name ‘springapp’ 2010-01-24 17:25:01,778 WARN
[http-8080-3] servlet.DispatcherServlet (DispatcherServlet.java:962) –
No mapping found for HTTP request with URI
[/springapp/static/css/scrollable-buttons.css] in DispatcherServlet
with name ‘springapp’

Going to
http://localhost:8080/springapp/shop works fine but the css and images are missing.

I think that using Tiles is somehow complicating things but I”m reluctant to get rid of it. I’m wondering if I need to adjust my view resolution configuration needs to be tweeked somehow? Chaining view resolvers maybe? I’m just not that experienced in doing that.

  • 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-13T14:52:31+00:00Added an answer on May 13, 2026 at 2:52 pm

    The problem is that requests for the static content go to the dispatcherServlet, because it’s mapped as <url-pattern>/</url-pattern>. It’s a very common problem in applications with “RESTful” URLs (that is, without any prefix in the DispatcherServlet mapping).

    There are several possible ways to solve this problem:


    Since Spring 3.x the preferred way to access static resources is to use <mvc:resources>:
    web.xml:

    <servlet-mapping> 
        <servlet-name>springapp</servlet-name> 
        <url-pattern>/</url-pattern> 
    </servlet-mapping>
    

    Spring config:

    <!-- Handles GET requests for /resources/** by efficiently serving static content 
        in the ${webappRoot}/resources dir --> 
    <mvc:resources mapping="/resources/**" location="/resources/" /> 
    

    See also MVC Simplifications in Spring 3


    1. Use URL rewrite filter
    See mvc-basic example here

    2. Set a prefix for the default servlet:

    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/static/*</url-pattern>
    </servlet-mapping>
    

    That is, request for /static/images/image.png will return the file named /images/image.png
    However, this way is incompatible across different servlet containers (doesn’t work in Jetty), see workarounds here

    3. Set static content extensions for the default servlet:

    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.png</url-pattern>
        <url-pattern>*.js</url-pattern>
        <url-pattern>*.css</url-pattern>
    </servlet-mapping>
    

    4. Do not use RESTful URLs, use URLs with prefix:

    <servlet-mapping> 
        <servlet-name>springapp</servlet-name> 
        <url-pattern>/app</url-pattern> 
    </servlet-mapping>
    

    5. Do not use RESTful URLs, use URLs with extension:

    <servlet-mapping> 
        <servlet-name>springapp</servlet-name> 
        <url-pattern>*.do</url-pattern> 
    </servlet-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I need to clean up various Word 'smart' characters in user input, including but

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.