Reputation: 3930
I have problem with .css file on my JSP page.
My page looks like this:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
...
<link href="test.css" rel="stylesheet" type="text/css">
...
<body>
<div id="header">....
When I deploy my application on JBoss5.1 a get a warn message:
WARN [PageNotFound] No mapping found for HTTP request with URI [/appTest1-web/test.css] in DispatcherServlet with name 'appTest1'
Anybody know why?
ADDED
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>appTest1</display-name>
<servlet>
<servlet-name>appTest1</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appTest1</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
Upvotes: 1
Views: 2890
Reputation: 47
I think you somewhere else in xml make mistake, but in more advanced redirection you can use UrlRewrite filter http://www.tuckey.org/urlrewrite/
Upvotes: 0
Reputation: 32111
Is the base URL that you're using to call this page: /appTest1 by chance?
I assume you simply have placed this page/controller under /appTest1 and thus when it looks for any resource on the page (e.g. your css, any image, js's, etc) it is looking under "/appTest1/your_resource"
Perhaps the class that contains your controller has something like @RequestMapping("appTest1")? or perhaps that's a JBoss artifact (if so, I'm not a JBoss guy, so can't suggest ideas there).
In any case, your CSS file should probably be referenced appropriately with either "../test.css", or the static reference, such as: "/static/css/test.css", I choose the latter.
Incidentally, in spring I configured a static directory for non-dynamic content with:
<mvc:resources mapping="/public/**" location="/public/"/>
Large scale websites also consider putting static content under a separate domain such as static.mydomain.com or mycontentdomain.net to avoid having cookies passed along with static content.
Hope all that helps you get yourself pointed in the right direction.
Upvotes: 2
Reputation: 2174
Seems like your DispatcherServlet is trying to process the test.css. Check your web.xml to see if * or .css requests are directed to your DispatcherServlet. You should look for something like below. Make sure to limit the url-pattern to the extensions you want to be directed to the dispatcher servlet.
<servlet-mapping>
<servlet>dispatcher</servlet>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Upvotes: 0