enter image description here開かれたホームページアプリケーションが開かれていません
このi mageショーフォルダー。
次のサーブレットコード:
import java.io.IOException;
//import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(name = "HomeServlet", urlPatterns = {"/home"})
public class HomeServlet extends HttpServlet {
public HomeServlet() {
super();
}
/*protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// Forward to /WEB-INF/views/homeView.jsp
// (Users can not access directly into JSP pages placed in WEB-INF)
request.getRequestDispatcher("/Career/WebContent/WEB-INF/views/index.jsp").forward(request, response);
// dispatcher.forward(request, response);
}*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.getRequestDispatcher("/index.jsp").forward(request, response);
}
}
次のインデックスjspページ:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<link rel="stylesheet" href="${contextPath}/css/styles.css"
type="text/css" />
</head>
<body>
<div id="wrapper">
<div class="header" id="header"></div>
<div class="navbar">
<ul>
<li><a href="/index.jsp">Home</a></li>
<li><a href="#">Profile</a></li>
<li><a href="job_offer.html" target="_blank">Offer a job</a></li>
</ul>
<a href="index.html" target="_blank"><img
src="${contextPath}/images/meterbrain.gif"
style="float: right; width: 12%;" /></a>
</div>
<div class="content">
<div class="rightblock">
<div class="headmenu">Prolog System</div>
<div class="bodymenu">
<a href="#"><img src="${contextPath}/images/meterbrain.gif" /></a>
</div>
</div>
<div class="leftblock">
<div class="headmenu">Advertisements</div>
<div class="bodymenu" id="advertise1">
<a href="#"><img src="${contextPath}/images/advertisement.jpg" /></a>
</div>
<div class="bodymenu" id="advertise1">
<a href="#"><img src="${contextPath}/images/advertisement.jpg" /></a>
</div>
<div class="bodymenu" id="advertise1">
<a href="#"><img src="${contextPath}/images/advertisement.jpg" /></a>
</div>
</div>
次のweb.xml:
<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Career</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
と別の問題 私はこのページを実行する場合なぜ私はCSSと画像をJSPにインポートできないのですか?これらのファイルをEclipseフォルダに追加します。画像プロジェクトフォルダの
最終更新:まだ
は、JSPファイル内のCSSや画像をインポートすることはできません。 と同じ問題があり、別のJSPページをリクエストしています。 助けてください。
WEB-INFからあなたのindex.jspを外に移動し、私はWEBCONTENTでJSPを追加する場合にのみ、それが動作していない理由のWebContent – PacMan
に直接それを置きますか?もしjspファイルを追加したいのであれば、どうすればいいですか?どのフォルダに私はCSSとイメージファイルを追加しますか? – Magician
それはwebContentのすべてです、あなたはそれをcssと別の1つのイメージと別の1つは、それをmyJspとあなたのオーウェンのページとスタイルシートを編集することができますを呼び出すフォルダを作成することができますそれの下の答えを参照してください – PacMan