Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

url - JSP doesn't open CSS, Images and JS

I'm trying to put CSS, JS and IMGs on my JSP, but doesn't work, it's strange because I use c:url and JSTL core.

I'm using JSP, JSTL and Servlet, no frameworks.

structure

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>clientes atuantes</title>
        <link rel="stylesheet" href="<c:url value="/bootstrap/css/bootstrap.min.css"/>">
        <link rel="stylesheet" href="<c:url value="/css/layout.css"/>">
        <script type="text/javascript" src="<c:url value="/bootstrap/js/jquery-1.12.0.js" />"></script>
        <script type="text/javascript" src="<c:url value="/bootstrap/js/bootstrap.min.js" />"></script>
    </head>
    <body>

        <main>
            <div class="col-md-12">
                <div class="panel panel-default espacamentoExterno5">

                    <div class="panel-body">
                        <p><img src="<c:url value="/img/ativo.gif"/>" /> ativo</p>
                        <p><img src="<c:url value="/img/congelado.gif"/>" /> congelado</p>
                        <p><img src="<c:url value="/img/cancelado.gif"/>" /> cancelado</p>

                    </div>
                </div>
            </div>
        </main>
    </body>
</html>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns:web="http://java.sun.com/xml/ns/javaee" 
         xmlns="http://java.sun.com/xml/ns/javaee" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    
  <display-name>PainelProduct</display-name>
  

</web-app>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are not escaping the " when using inside the href value, use ' instead


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...