java - 不使用正则表达式从查询字符串中删除一个参数

标签 java spring string servlets request

所以我有一个网址

String url = request.getRequestURL()+"?"+request.getQueryString();

有一个参数 Custom="true",我想在将其存储在 url 中之前将其删除。 有没有有效的方法来做到这一点,而不使用正则表达式。

Example - 

 http://myhost:8080/people?lastname=Fox&age=30&Custom=true&verified=yes

 request.getQueryString();  // "lastname=Fox&age=30&Custom=true&verified=yes"

Desired o/p - lastname=Fox&age=30&verified=yes

最佳答案

只需将 Custom=true 替换为空字符串

query = query.replace("Custom=true&",""); 

关于java - 不使用正则表达式从查询字符串中删除一个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55179996/

相关文章:

Javamail 无法连接

javascript - GWT 项目中未触发浏览器拖动事件

java - Intellij IDEA : equivalent of Eclipse's "Complete Current Statement" (Ctrl+Shift+Enter)?

c# - 在 C# 中删除二维字符串数组的行

c# - String.Replace CRLF 为 '\n'

string - 用字典替换子字符串的最快方法(在大型数据集上)

java - while 循环,为 java 中的下一个 while 循环存储值

java - 在 Spring Boot 测试中测试 @Cacheable : Caffeine cache not invoked on MockBean

java - 我们在 Spring 中需要同时使用 @Transactional 和 @Modifying 注解吗?

spring - 如何将 Spring Boot 应用程序作为服务运行?