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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:28:25+00:00 2026-05-29T10:28:25+00:00

I would like to collect all css/js resources in a controller. This would result

  • 0

I would like to collect all css/js resources in a controller.

This would result in one HTTP Request for each resource.

Example:

package my.package;

// [...imports...]

@Controller
@RequestMapping( "/res" )
public class ResourcesController
{
  @RequestMapping( value = "/style.css", headers = "content-type=text/css" )
  // [...] collect all css files from /WEB-INF/css/**

  @RequestMapping( value = "/scripts.js", headers = "content-type=text/javascript" )
  // [...] collect all js files from /WEB-INF/js/**
}

I already have an DispatcherServlet which uses Apache Tiles, so I guess i need to make a new servlet?!

<servlet>
  <servlet-name>resources</servlet-name>
  <servlet-class>?org.springframework.web.servlet.ResourceServlet?</servlet-class>
  <load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
  <servlet-name>resources</servlet-name>
  <url-pattern>/res/*.css</url-pattern>
  <url-pattern>/res/*.js</url-pattern>
</servlet-mapping>

Is class org.springframework.web.servlet.ResourceServlet correct?

What I have to put in my resources-servlet.xml then? This?

<?xml version="1.0" encoding="utf-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context.xsd">

  <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver" />

  <context:component-scan base-package="my.package" />

</beans>

And how my mapping methods should look like in the controller?
Any example code would be very useful. Can’t find anything on the internet…

  • 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-29T10:28:26+00:00Added an answer on May 29, 2026 at 10:28 am

    I already have an DispatcherServlet which uses Apache Tiles, so I guess I need to make a new servlet?!

    No — you should have only the DispatcherServlet. — Every Spring Controller is handled by this servlet.


    But in general it looks strange what you do.

    • Spring already have a “tool” that allows to access static ressources ResourceHttpRequestHandler See Spring Reference Chapter 16.14.5 Configuring Serving of Resources

    for example

       <mvc:resources location="/, classpath:/META-INF/web-resources/"
        mapping="/resources/**" />
    
    • But maybe you try something more complex like Jawr?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, I have 4800 and I would like to see all the factors
I am trying to parse large zipped logfile and would like to collect all
I would like to collect all possible ways with which JavaScript can be defined
I'm working with a simple select like this: <%= select(@file, @file.file_id, File.all.collect {|p| [
I have various models of which I would like to keep track and collect
I collect a few corner cases and brain teasers and would always like to
I would like to generate a graph like the link below http://en.wikipedia.org/wiki/Reaction_coordinate The graph
I would like to return a string with all of the contents of a
We have a List of items: List<X> from this List, we would like to
Basically all I would like to do is export a whole html table to

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.