• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to incluse a css file in spring

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am unable to include a css file in my jsp. My configurations are as follows:-

web.xml

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>

</servlet>

<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/edo/*</url-pattern>
</servlet-mapping>

spring-servlet.xml
<bean name="/home"
class="com.protogalaxy.edo.web.HomeController">
</bean>

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp"/>
</bean>

JSP page

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<link href="scripts/mystyle.css" rel="stylesheet" type="text/css"/>
</head>

Controller code
ModelAndView mav = new ModelAndView("home");

URL
http:// localhost/MYAPP/edo/home

My jsps are in WEB/-inf/jsp/home.jps and my css file is in WEB-INF/jsp/scripts/mystyle.css. Could anyone please help me in knowing what I am missing?
Thanks in advance.


Thanks
Andy
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Nothing under WEB-INF can be served. Move any CSS, script and image files out of WEB-INF.

2) Avoid page-relative URLs. User server-relative URLs. See the JSP FAQ.
 
Bear Bibeault
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a general JSP issue, so it's been moved to the JSP forum.
 
andy kumar
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for the quick reply. Following your suggestion I was successfully able to include my css file in the jsp page.

Once again thanks for the help.

Thanks
Andy
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic