これは、 Spring MVC アプリの jsp ページでのリソースへのアクセスに関する質問へのフォローアップです @kmb385 のおかげで、その問題を解決できましたが、JSP ファイル javax.servlet.jsp.JspException cannot be で次の eclipse エラーが発生しますタイプに解決され、
javax.servlet.jsp.PageContext を型に解決できません
kmb385 で提案されているように、これが私のコントローラーです。
@Controller
public class AdminController {
@RequestMapping("/")
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView model = new ModelAndView("index");
model.addObject("msg", "hello world");
return model;
}
}
念のため、ここに私のindex.jspページがあります:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<!-- <link type="text/css" rel="stylesheet" href="css/style.css"/> -->
<style type="text/css">
<%@include file="css/style.css" %>
</style>
<title>My Project - MainPage</title>
</head>
<body>
<h2 class="main_heading2">My Project - MainPage</h2>
<div style="float: right; width: 30%; text-align: center">
<p style="float:left;">an image should be here</p>
<img src="images/logo.jpg" alt="Logo"/>
<img src="${pageContext.servletContext.contextPath}/resources/images/logo.jpg" />
</div>
</body>
JSPバリデーターで無効にすることで、これに対する「解決策」に出くわしましたが、正当な理由がない限り、これを提案しないでください。私はむしろこの問題を適切に修正したいと思います
助けていただければ幸いです
更新:
@kmb385 のリクエストに応じてパス画面グラブを作成します