- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下 servlet 读取 url 路径参数。问题:如果输入包含特殊字符,例如我发现#
,那么字符串会被截断!
@RestController
public class MyServlet {
@GetMapping("/hash")
@ApiIgnore
public String hash(HttpServletRequest req) {
String pw = req.getPathInfo(); //asdfgh
}
}
`localhost:8080/hash/asdfgh#jkl`
问题:如何原生传递输入参数?
最佳答案
从 #
开始的部分不会发送到您的 servlet,也不会被您的 servlet 接收。
这是仅从客户端(浏览器)使用的信息,不会使URI 的一部分。
RFC2396确实指出:
When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, separated from the URI by a crosshatch ("#") character, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed. As such, it is not part of a URI, but is often used in conjunction with a URI.
关于java - 为什么 HttpServletRequest 会截断 # 字符上的 url 输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49516146/
这两个人似乎在做同样的事情。谁能解释两者之间的主要区别?你什么时候使用一个与另一个? HttpServletRequest.getRemoteUser() HttpServletRequest.get
我现在尝试了很多东西,但我似乎错过了一 block 拼图。这是故事:我有一个请求范围的 bean,它从 HttpServletRequest 读取一些 SessionContext。此属性在过滤器中设
使用HttpServletRequest.login(String, String)登录后,使用以下代码,在以下请求中,我仍然会收到基本身份验证提示。为什么login函数在我的配置中不起作用? 我的终
我为 HttpservletRequest 设置路径信息,如下所示。 request.setAttribute("javax.servlet.include.path_info", pathInfo)
我在表单和请求方面遇到了这个问题。我正在使用 sencha 和 javascript 创建一个网页,该网页将表单发布到 java Web 应用程序,该应用程序从数据库中提取数据并对其进行格式化,然后再
我曾经在 JSF 2 应用程序中基于 cookie 的对话过滤器中打开 session 。现在我想建立相同的机制,但与技术无关。重用一些代码,我将其编写在扩展 OncePerRequestFilter
我从我的客户端向我的服务器发送一个 ajax 请求。 这是我传递的数据结构: data = {"key1" : "value1" , "key2" : {"subkey1": "subvalue1"
如何使用 HttpServletRequest 中的信息识别集群中的节点? 每个节点唯一的任何信息都是合适的 - 我需要它来区分日志。 最佳答案 你可以尝试获取IP和hostname // Get c
我过滤我的 REST 服务的 BasicAuth 并将用户名存储在 HttpServletRequest 中 AuthFilter相关代码 public class AuthFilter implem
我想实现一个速度工具,它提供了一种方法来查明用户是否登录。我正在使用 VelocityLayoutServlet 以便在每个请求上呈现模板。 我的 velocity-tools.xml 看起来像这样:
我正在 Spring MVC 上 Swagger 玩,运行本地 jetty ,由于某种原因得到一个 null HttpServletRequest,至少可以说这很奇怪。 这是完整的堆栈跟踪: java
Class Permission implements ContainerRequestContext { @context HttpServletRequest servletReq
我在启用双向 SSL 的 Weblogic 10.3 中运行一个 servlet。当我尝试从 HTTPServletRequest 获取以下属性时,它们都是空的: - javax.servlet.re
我已经导入了以下内容导入 javax.servlet.http.*; 我想获取首选语言的浏览器 HttpServletRequest request = ServletActionContext.ge
我想拦截过滤器/servlet 中的请求并向其添加一些参数。但是,该请求不会公开“setParameter”方法,并且在操作参数映射时会抛出一个错误,说明它已被锁定。有没有我可以尝试的替代方案? 最佳
为了测试,我想从一些预定义的数据构建 HttpServletRequest 对象,例如: GET / HTTP/1.1 User-Agent: Opera/9.80 (Windows NT 6.1;
在我的 servlet 中,req.getQueryString() 在向其发送 ajax 请求时返回 null。这是因为 req.getQueryString() 只适用于 GET 而不是 POST
我使用打印编写器直接在 servlet 中打印列表,然后打印列表。 当我尝试放入 jsp 时,列表不会打印我使用的是 JSTL 还是 scriptlet。 我尝试在 JSTL 和 scriptlet
我有一个 jsp,其中包含一个 jquery post 到我的 tomcat 服务器上的一个 servlet,它创建了一个 HttpServletRequest。我想确保只处理我的 jsp 对我的 s
我对HttpServletRequest生命对象有疑问。 request对象进入controller后是否被销毁? 最佳答案 HttpServletRequest 对象的生命周期就是:为 HTTP S
我是一名优秀的程序员,十分优秀!