小编And*_*And的帖子

如何在dispatcher.forward(request,response)之后从servlet中获取请求中的上一页URL

我正在使用servlet,它借助于重定向我

dispatcher.forward(request, response);
Run Code Online (Sandbox Code Playgroud)

到底.但在此之后我想获取我被重定向的页面(路径)以在下一个servlet命令中使用它(转到上一页).我怎么能得到它?或者以前的URL不包含在请求参数中,我应该自己添加它?非常感谢你的帮助.

servlets request

12
推荐指数
2
解决办法
3万
查看次数

编码.properties或JSP有问题

我有jsp文件:

   <%@ page language="java" contentType="text/html;
charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="language"
    value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}"
    scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="localization.text" />
<!DOCTYPE html>
<html lang="${language}">
<head>
<title>JSP/JSTL i18n demo</title>
</head>
<body>
<form accept-charset="UTF-8"><select id="language"
    name="language" onchange="submit()">
    <option value="en" ${language=='en' ? 'selected' : ''}>English</option>
    <option value="ru" ${language=='ru' ? 'selected' : ''}>Russian</option>
</select></form>
<form name="loginForm" method="POST" action="controller"><input
    type="hidden" name="command" value="login" /> <label for="login"><fmt:message
    key="login.label.login" />:</label> …
Run Code Online (Sandbox Code Playgroud)

encoding jsp properties utf-8 internationalization

9
推荐指数
1
解决办法
4194
查看次数

如何将JSP放入WEB-INF中?

我正在使用MVC并希望将我的JSP页面放在WEB-INF中以避免直接访问它.我有一个index.jsp页面和Web内容的jsp文件夹中的其他页面,它的工作原理.它看起来像这样:

-Web Content
-index.jsp
-jsp
--main_read.jsp
--...
Run Code Online (Sandbox Code Playgroud)

顺便说一句,index.jsp是我的登录页面,用户是否已登录,在我使用的控制器中

RequestDispatcher dispatcher =
        getServletContext().getRequestDispatcher("jsp/main_read.jsp");
dispatcher.forward(request, response);
Run Code Online (Sandbox Code Playgroud)

我工作得很完美,但是当我试图将我的JSP放入WEB-INF时它会失败:

-Web Content
-index.jsp
-WEB-INF
--jsp
---jsp
----main_read.jsp
----...
Run Code Online (Sandbox Code Playgroud)

并给出这样的错误

HTTP Status 404 - /Libruary/jsp/main_read.jsp

type Status report

message /Libruary/jsp/main_read.jsp

description The requested resource (/Libruary/jsp/main_read.jsp) is not available.
Apache Tomcat/6.0.26
Run Code Online (Sandbox Code Playgroud)

可能问题是在页面路径中,我写了dispatcher.forward,但无论如何,请帮助我.

model-view-controller jsp web-inf

3
推荐指数
1
解决办法
3875
查看次数