【发布时间】:2019-05-28 19:06:53
【问题描述】:
当前状态:
https://localhost:8443/workaround/?query=dasda&atn=s&filterSoftwareType=ANY.....
期望的状态: https://localhost:8443/workaround/?q=dasda&atn=s&fst=ANY.....
使用 q 代替 query 和 fst 代替 filterSoftwareType 来缩短 url
我的 thymeleaf html 看起来像这样,简短的示例:
<form action="#" class="card card-sm rounded"
method="get"
th:action="@{${T(com.bisciak.workaround.util.Utils).MAPPING_INDEX}}" th:object="${search}">
<div class="col">
<input class="form-control form-control-lg form-control-borderless"
placeholder="Search here"
style="padding-left: 1rem"
th:field="${search.query}" type="search"/>
</div> etc...
控制器:
@GetMapping(value = Utils.MAPPING_INDEX, params = "atn=s")
public ModelAndView indexActionSearch(@ModelAttribute(name = "s") Optional<Search> search .....
搜索对象具有查询等属性,但我不想重命名这些属性!通过我只想为 URL 使用简短版本的代码,这将是一个可怕的命名。
有人知道怎么做吗?我在输入芽上尝试了 name 属性,但没有帮助:/.
我还想保留表单中的内容,以便自动构建 url。 我还想将此保留为 get 而不是帖子,以便用户可以通过 URL 栏中的复制粘贴等轻松共享此链接。有了帖子,他就看不到了。
【问题讨论】: