Announcement Announcement Module
Collapse
No announcement yet.
Static content problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Static content problem

    Hi gurus,
    I'm completely new to web technologies and try to write my first Spring MVC application. I have following problem:
    My project has following structure:
    - WEB-iNF
    classes - compuled java code (controllers etc.)
    views - jsp pages
    lib - Spring and other libraries
    css - folder with my css files
    I use <mvc:resources> in following way:
    Code:
    <mvc:resources mapping="/resources/**" location="/css/" cache-period="31556926" />
    My understanding here is that I "map" /resources to /css directory.
    I run my application using Glassfish server (ver. 3.1.2) and see in the log following enrty:
    Code:
    Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
    It seems to be OK. Next I'll try to use my css file within jsp using:
    Code:
    <link rel="stylesheet" href="<s:url value="/resources/main.css" />" type="text/css">
    where s points to :
    Code:
    <%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
    And this doesn't work without any information. I'll try to get access to main.css file directly from the browser but always get HTTP Status 404 - The requested resource is not available. Any help will be very appreciated.

  • #2
    Your css directory should go under /src/main/webapp/resources, not web-inf (assuming you're using a maven project directory format).

    Comment


    • #3
      Hi,
      You're right I have MAVEN project nad move folder as you mentioned but it doesn't help
      I suspect that something is wrong with jsp page. when I look at page source (from browser side) following code is displayed:
      Code:
       <link rel="stylesheet" href="/RPC/resources/main.css" type="text/css">
      My jsp file looks like
      Code:
      <link rel="stylesheet" href="<s:url value="/resources/main.css" />" type="text/css">
      It seems that phrase /resources/main.css is not mapped to /css/main.css as I expect.

      Comment


      • #4
        Did you move the whole css directory under resources? If so your url would be "<s:url value="/resources/css/main.css"

        Comment


        • #5
          Yes I move whole css directory. I change s:url tag but without success. I thought that mvc:resources tag mapps all static content to /css directory directly.

          Comment

          Working...
          X