我有这个输入表:
<div class="searchBox">
<form data-th-object="${findHotel}" method="get" data-th-action="@{/search}">
<input class="searchBoxTextEditor" type="text" placeholder="Enter name of the hotel" data-th-field="*{name}">
<input type="submit" value="find">
</form>
</div>
此表格适用于模型:
public class FindHotel {
private String name;
public FindHotel(String name) {
this.name = name;
}
public FindHotel() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
此类控制器:
@GetMapping("/search")
public String getSearchRedirect(FindHotel findHotel){
return "redirect:/search/" + findHotel.getName();
}
@GetMapping("/search/{text}")
public String getSearchResultPage(@PathVariable(name = "text")String text,Model model){
List<Hotel> hotels = hotelService.findHotelByNameLike(text);
model.addAttribute("hotels",hotels);
return "hotels";
}
如何在不重定向的情况下更改take result的此操作url @GetMapping
. 我需要把结果放进我的电脑里 @GetMapping
从数据库获取信息的方法。我怎样才能改变它?
<form data-th-object="${findHotel}" method="get" data-th-action="@{/search}">
<input class="searchBoxTextEditor" type="text" placeholder="Enter name of the hotel" data-th-field="*{name}">
<input type="submit" value="find">
</form>
1条答案
按热度按时间bwitn5fc1#
如果您确实需要转到search/{text}但不想重定向,您可以通过javascript来实现,例如:
html格式:
js公司: