这是 StrutsAction
类:
public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = null;
try {
forward = mapping.findForward(request.getParameter("nextPage"));
// response.getWriter().print(request.getSession().getServletContext().getRealPath("."));
} catch (Exception ex) {
ex.printStackTrace();
} finally {
return forward;
}
}
这是根据先前解决的 ActionForward 实例的 JSP:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Description</title>
<script src="/jsp/html5/sencha-touch/sencha-touch.js" type="text/javascript"></script>
<link href="/jsp/html5/sencha-touch/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/jsp/html5/description.js"></script>
</head>
<body>
</body>
</html>
上面这个文件的路径已经过调整,以便它们相对于Action
类的当前工作目录。但是,浏览器中不会显示任何内容。恢复到原始路径(并直接访问 JSP 文件,而不是通过Action
类)在浏览器中输出所需的页面:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Description</title>
<script src="./sencha-touch/sencha-touch.js" type="text/javascript"></script>
<link href="./sencha-touch/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./description.js"></script>
</head>
<body>
</body>
</html>
[-EDITED-] 我的需要是完成Action
课程,所以我必须以某种方式解决这种情况。包含的 JavaScript / CSS 文件不包含其他文件,所以我不知道问题是否真的与工作目录有关以及如何。
有什么意见吗?谢谢