I am new to Java and Spring. I encountered the error trying to apply CSS styles. Here is my jsp:
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:display="urn:jsptld:http://displaytag.sf.net"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:spring="http://www.springframework.org/tags">
<jsp:directive.page contentType="text/html; charset=UTF-8" />
<jsp:directive.page import="test1.domain.*" />
<html>
<head>
<title>CD Catalog</title>
<link href='<c:url value="/css/displaytag.css" />' rel="stylesheet" type="text/css" />
</head>
and so on...
The css folder is on the same level where WEB-INF is.
In my servlet.xml I have:
<mvc:resources mapping="/**" location="/*" />
The next error I get:
HTTP Status 500 - /WEB-INF/jsp/test_task.jsp(11,15) The value of attribute "href" associated with an element type "null" must not contain the '<' character.
I tried also single and double quotes the other way round, and tried the same double quotes, but it wasn't successful.
I would appreciate any advice. Thank you in advance.
Please add tag library declaration <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
to the header. The taglib directive declares that your JSP page uses a set of custom tags( c:url
here), and identifies the location of the library. Without that indication, your JSP file will end up with a ( href
) attribute containing an unescaped <
character, which is not a valid XML.
UPDATE :
Just realize you are using JSP document instead of JSP page, and you've already declared namespace xmlns:c
, so taglib isn't needed any more. Since JSP document strictly requires well-formed XML document, it complains about your link's href attribute(with unescaped <
inside). To avoid that, try:
<c:url var="url" value="/css/displaytag.css" />
<link href="${url}" rel="stylesheet" type="text/css" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.