aspose file tools*
The moose likes Spring and the fly likes Tiles not picking up stylesheet in Spring app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Tiles not picking up stylesheet in Spring app" Watch "Tiles not picking up stylesheet in Spring app" New topic
Author

Tiles not picking up stylesheet in Spring app

Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61


I went through a Spring/Tiles/Hibernate tutorial and tried to adapt it to my purposes. The functionality within the application works. I am able to delete and insert records, display them on a form, etc. However, the layout page is not picking up my stylesheet. The stylesheet reference is correct. My jsps are located in the WEB-INF/jsp folder.

Part of my problem seems to be the url pattern I have defined in the web.xml, which is just "/".

This allows me to create request mappings of /index or /add or /delete.

Please let me know what other information I need to post to help dissect the problem.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I'm not sure what it means for a layout page to "pick up" a stylesheet. So I'm going to assume that you mean that when the result of all the Spring and Tiles business appears in your browser, it isn't styled according to the stylesheet you expected to be used. I'm also going to assume that the HTML which you see in the browser does actually contain a reference to that stylesheet.

Now remember that it's the browser that styles the HTML, not Spring or Tiles or JSP or anything on the server. And the browser has no idea what ran on the back end, all it knows is that it was given some HTML to work with.

So there are two possibilities: the reference to the stylesheet isn't correct, or it doesn't work. If you think you know the absolute URL of the stylesheet, you can type or paste that URL into your browser's address bar and see what comes back. If you do see a stylesheet when you do that, then that means the reference to the stylesheet in the HTML doesn't resolve to that absolute URL. Anyway that's the sort of testing you need to do.
Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61
When I change the url mapping to
[code]
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
[/code]

I can't view the stylesheet with the absolute url.

However, when I change the url mapping to
*.html

Then I can...doesn't make sense.
Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61
This is how I solved this...I created a separate context, or application called "themes" in my Tomcat webapps directory. I put the css file in there.

Then from my spring application, I referred to the "themes" stylesheet in this matter...in my layout.jsp.

<link rel="stylesheet" href="/themes/styles.css" type="text/css" />

In the end, this was some type of routing issue. I still used the url-pattern of /

I'm not sure how I would have resolved this by keeping the themes directory in my own application.

Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61
It's entirely possible this had NOTHING to do with Spring, so my apologies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tiles not picking up stylesheet in Spring app