Jsp page as css file on Tomcat

I want to have a css file, which is actually a jsp page. One of the reasons is that I would like to use c: url tags to make the path to images context-independent.

So far, I have only found the ability to install this in server.xml. But I only need this for my webapp, and not for the entire server.


Update: Setting the content type to text / css certainly works. But that still leaves me with style.jsp, whereas I want the file to be called style.css. One reason would be that the work of Eclipse-highlighting and autocomplete is done.

+3
source share
2 answers

. - HTTP Content-Type. .

JSP :

<%@ page contentType="text/css" %>

.

HTTP Content-Type, Content-Type servletcontainer/webserver. , .


: , .css , IDE . : CSS servlet-name JspServlet, servlet. Tomcat jsp.

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>/style.css</url-pattern>
</servlet-mapping>

, webapp . servletcontainers, jsp servlet-name.

+2

jsp . mime jsp.

+1

Source: https://habr.com/ru/post/1759596/


All Articles