[Logo]
Forums Register Login
Unable to incluse a css file in spring
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
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.
This is a general JSP issue, so it's been moved to the JSP forum.
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
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 24, 2017 08:21:20.