Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么Eclipse中的jsp页面不';是否将图像显示到img标签中?_Java_Html_Jsp - Fatal编程技术网

Java 为什么Eclipse中的jsp页面不';是否将图像显示到img标签中?

Java 为什么Eclipse中的jsp页面不';是否将图像显示到img标签中?,java,html,jsp,Java,Html,Jsp,我试图将一个动态web项目编码到Eclipse中,但是jsp页面中的标记img不起作用。这是我的项目: ProjectName --WebContent --WEB-INF --images page.jsp 这是我的jsp代码: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <

我试图将一个动态web项目编码到Eclipse中,但是jsp页面中的标记img不起作用。这是我的项目:

ProjectName
   --WebContent
        --WEB-INF
             --images
   page.jsp
这是我的jsp代码:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="Beans.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>HomePageImpiegato</title>
    <style>
        body{color: #333;font-family: 'Muli', sans-serif;background-color: #F5F5F5;}
        h1{font-family: 'Open Sans Condensed', sans-serif;font-size: 30px;color: #333;width: fit-content;margin-left: auto;margin-right: auto;}
        h4{font-family: 'Open Sans Condensed', sans-serif;font-size: 20px;color: #333;width: fit-content;margin-left: auto;margin-right: auto;}
        .preventivi{height: fit-content;display: flex;width: 100%;}
        .preventiviGestiti{float: left;margin-left: auto;margin-right: auto;width: 48%;}
        .preventiviLiberi{float: right;margin-right: auto;margin-left: auto;width: 48%;}
        .dati-personali{margin: auto;width: fit-content;}
        .gestisciPreventivo{margin-left: auto;margin-right: auto;width: fit-content;margin-top: 50px;}
        #preventivi {font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;border-collapse: collapse;width: 100%;}
        #preventivi td, #preventivi th {border: 1px solid #ddd;padding: 8px;}
        #preventivi tr:nth-child(even){background-color: #f2f2f2;}
        #preventivi tr:hover {background-color: #ddd;}
        #preventivi th {padding-top: 12px;padding-bottom: 12px;text-align: left;background-color: #4CAF50;color: white;}
</style>
</head>
<body>
    <div class="contenuto">
    <h1>Home Page Impiegatodiv</h1>
    <%
        Utente utente = (Utente) session.getAttribute("utente");
        if (utente==null) {
            response.sendRedirect(getServletContext().getContextPath() + "/LoginPage.html");
        }
        else {
            if (utente.getTipo().equals("cliente")) {
                response.sendRedirect(getServletContext().getContextPath() + "/LoginPage.html");
            }
            else {
                %><div class="dati-personali"><%
                out.println("Ciao " + utente.getTipo() + " " + utente.getNome());
                out.println(" Con password " + utente.getPass());
                %></div><%
                Preventivo[] preventivi = (Preventivo[]) session.getAttribute("preventiviU");
                Preventivo[] preventiviNull = (Preventivo[]) session.getAttribute("preventiviN");
                %><div class="preventivi">
                    <div class="preventiviGestiti">
                    <h4>Preventivi gestiti in passato</h4>
                    <%
                    if (preventivi==null) {
                        out.println("Nessun preventivo");
                    }
                    else {
                    for (int i=0; i<preventivi.length; i++) {
                        %>
                        <table id="preventivi">
                            <tr>
                                <th><img src="<%= request.getContextPath()%>/WEB-INF/images/<%= preventivi[i].getImg() %>"></th>
                                <th><% out.println(preventivi[i].getId()); %></th>
                                <th><% out.println(preventivi[i].getCliente()); %></th>
                                <th><% out.println(preventivi[i].getImpiegato()); %></th>
                                <th><% out.println(preventivi[i].getPrezzo()); %></th>
                                <th><% out.println(preventivi[i].getNomeProdotto()); %></th>
                            </tr>
                        <%
                            Opzione[] opzioni = preventivi[i].getOpzioni();
                            for (int j=0; j<opzioni.length; j++) {%>
                            <tr>
                                <th><% out.println(opzioni[j].getNome()); %></th>
                                <th><% out.println(opzioni[j].getTipo()); %></th>
                            </tr>

                        <%
                            }
                        %></table><%
                    }
                %></div><%
                }
                %><div class="preventiviLiberi">
                    <h4>Preventivi da gestire</h4>
                <%
                    for (int i=0; i<preventiviNull.length; i++) {
                        %><table id="preventivi">
                            <tr>
                                <th><img src="<%= request.getContextPath()%>/WEB-INF/images/<%= preventiviNull[i].getImg() %>" height="42" width="42"></th>
                                <th><% out.println(preventiviNull[i].getId()); %></th>
                                <th><% out.println(preventiviNull[i].getCliente()); %></th>
                                <th><% out.println(preventiviNull[i].getImpiegato()); %></th>
                                <th><% out.println(preventiviNull[i].getPrezzo()); %></th>
                                <th><% out.println(preventiviNull[i].getNomeProdotto()); %></th>
                            </tr>
                            <%
                            Opzione[] opzioni = preventiviNull[i].getOpzioni();
                            for (int j=0; j<opzioni.length; j++) {%>
                            <tr>
                                <th><% out.println(opzioni[j].getNome()); %></th>
                                <th><% out.println(opzioni[j].getTipo()); %></th>
                            </tr>
                            <%
                            }
                        %></table><%
                    }
                    %></div><%
            %></div>    
        <div class="gestisciPreventivo">
            <h4>Gestisci preventivo</h4>
            <form action="gestisci" method="POST">
                    <select id="idPreventivoNew" name="idPreventivoNew">
                        <%
                            for (int i=0; i<preventiviNull.length; i++) {
                                %> <option value="<%= preventiviNull[i].getId() %>"> <%= preventiviNull[i].getId() %> </option> <%
                            }%>
                    </select>
                    <label>Scegli preventivo</label>
                    <input type="hidden" id="impiegato" name="impiegato" value="<%= utente.getNome() %>">
                    <input type="submit" value="PREZZA PREVENTIVO">
             </form>
        </div>
        </div>
        <%
        }
    }
    %>
</body>

主页Impiegato
正文{color:#333;字体系列:'Muli',无衬线;背景色:#f5;}
h1{字体系列:“开放式无压缩”,无衬线;字体大小:30px;颜色:#333;宽度:适合内容;左边距:自动;右边距:自动;}
h4{字体系列:“开放式无压缩”,无衬线;字体大小:20px;颜色:#333;宽度:适合内容;左边距:自动;右边距:自动;}
.preventivi{高度:适合内容;显示:灵活;宽度:100%;}
.preventivigestii{float:left;margin left:auto;margin right:auto;width:48%;}
.preventiviLiberi{float:right;margin right:auto;margin left:auto;width:48%;}
.dati personali{margin:auto;width:fit content;}
.gesticipreventivo{左侧边距:自动;右侧边距:自动;宽度:适合内容;顶部边距:50px;}
#preventivi{字体系列:“投石机MS”,Arial,Helvetica,无衬线;边框折叠:折叠;宽度:100%;}
#preventivi td,#preventivi th{边框:1px实心#ddd;填充:8px;}
#preventivi tr:n个孩子(偶数){背景色:#f2f2f2;}
#preventivi tr:hover{背景色:#ddd;}
#preventivi th{顶部填充:12px;底部填充:12px;文本对齐:左侧;背景色:#4CAF50;颜色:白色;}
主页Impiegatodiv
帕萨托的预防性孕体感染

我也尝试传递绝对路径,但只在Eclipse中工作,而不在浏览器中工作。 我也尝试更改我的浏览器,但没有任何结果。
谢谢

有一件事是肯定的:
WEB-INF
不应该在映像路径中,因为它不应该被应用程序服务器那样公开。禁止在
WEB-INF
中放置静态资源,如映像。http请求无法访问该文件夹的内容。可以肯定的是:
WEB-INF
不应位于映像路径中,因为它不应被应用程序服务器那样公开。禁止将静态资源(如映像)放置在
WEB-INF
中。http请求无法访问该文件夹的内容。