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 6797865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:39:41+00:00 2026-05-26T18:39:41+00:00

I have a basic directory app that works fine except that it seems to

  • 0

I have a basic directory app that works fine except that it seems to only sometimes find the static resources that I’ve configured using the mvc:resources tag. My search of the board found problems related to handler mappings, but my problem seems to be different.

Specifically, when the PersonController is called via a method mapping to “/person”, it returns personlist.jsp using the view resolver and correctly finds and uses the static css and js files. No problems.

When the same controller is called via another method mapping to “/person/{familyid}” ( narrows the person list to a particular family), it returns the same personlist.jsp…but now it fails to find or use the css and js files (though it does display the correct data).

I don’t understand why there is a behavior difference since both scenarios use the same Controller, the same return String (return “personlist”), and resolve to the same JSP (ie. with the same Head section links for the css, js).

I looked at what came back in the browser for each case using ‘view source’, and both pages return the same head tag rendering for the css and js linking:

<link href="resources/css/directory.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript" src="resources/scripts/jquery-1.7.min.js"></script>
<script type="text/javascript" src="resources/scripts/directory.js"></script>

I thought the problem could be with my tag mapping, so I also tried this:

 <resources mapping="**/resources/**" and
 resources mapping="resources/**" 

but no help.

Am I approaching the use of static resources properly here (and what is the right resources tag mapping if that’s the problem)? Thanks.

I am using Spring 3.0.6 and my css and js files are located under /WebContent/resources/css and /WebContent/resources/scripts respectively, which are mapped using the mvc:resource tag (see below).

PersonController:

@Controller
public class PersonController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    /**
     * Simply selects the home view to render by returning its name.
     */

    List<Person> personList;
    Boolean familyCalled = false;

    @Autowired
    PersonService personService;

    @RequestMapping(value="/people", method=RequestMethod.GET)
    public String people(Model model) {

        logger.debug("Received request to show peoplelist page");

        System.out.println("Running inside people() method of PersonController");
        personList = personService.getPersons();
        familyCalled = false;
        model.addAttribute("personList", personList);
        return "personlist";
        }

    @RequestMapping(value="/people/{familyId}", method=RequestMethod.GET)
    public String familyMembers(@PathVariable("familyId") String fid, Model model) {
        System.out.println("Running inside familyMembers() method of PersonController");
        personList = personService.getPersonsInFamily(fid);
        familyCalled = true;
        model.addAttribute("personList", personList);
        return "personlist";
        }

Servlet-Context.xml (without namespaces):

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- for transactions -->
    <tx:annotation-driven/>

    <!-- Needed for @PreAuthorize security on methods -->
    <aop:aspectj-autoproxy/>

    <context:annotation-config />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="resources/" />

        <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven/>

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <context:component-scan base-package="com.c3works.preps" />

</beans:beans>

personlist.jsp (Head section):

<head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</meta>
        <title>XXXXXXXXXXXXXXXXXXX</title>

        <link href="resources/css/directory.css" rel="stylesheet" type="text/css">
</link>

        <script type="text/javascript" src="resources/scripts/jquery-1.7.min.js">
</script>

        <script type="text/javascript" src="resources/scripts/directory.js">
</script>

    </head>
  • 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-26T18:39:42+00:00Added an answer on May 26, 2026 at 6:39 pm

    Your URLs are relative and therefore the browser is looking for the resources in the wrong place. (Check the resulting HTML code)

    One solution is to use the <spring:url> tag to build the urls of the resources.

    <spring:url var="banner" value="/resources/images/banner-graphic.png" />

    <img src="${banner}" />

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

Sidebar

Related Questions

So I have an MVC 2 app that uses the Active Directory Membership Provider.
I have a basic form with controls that are databound to an object implementing
I have a basic CRUD form that uses PageMethods to update the user details,
I have a basic ActiveRecord model in which i have two fields that i
I have a basic C# console application that reads a text file (CSV format)
I have a PHP app that uses a $_GET parameter to select JS/CSS files
I have a Django web app that I would like to use in a
I have a .net wpf app that I am deploying, including the .net4 client
I have a java console app that I'm writing, and I want people to
I have an MVC application that consists of a directory with all the necessary

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.