我正在尝试传递th:action
<form class="form-inline" th:object="${search}" method="get" action="search.html" th:action="@{'/hotels/'+${search.location}+'/'+${search.adults}+'/'+${search.dateCheckOut}+'/'+${search.dateCheckIn}}" id="search-hotel-form">
<select class="selectpicker form-control input-lt" th:field="*{location}" id="city">
<option value="delhi">Delhi</option>
</select>
<input type='text' th:field="*{dateCheckIn}" id="datetimepicker1" />
<input type='text' th:field="*{dateCheckOut}" id="datetimepicker2" />
</form>
然后是Spring MVC控制器部分
@RequestMapping(value = "/hotelsparam/{dateCheckIn}/{dateCheckOut}/{location}", method = RequestMethod.POST)
public ModelAndView searchHotel(@PathVariable("dateCheckOut") Date dateCheckOut, @PathVariable("dateCheckIn") Date dateCheckIn,@PathVariable("location") String location, BindingResult bindingResult) throws ParseException {....
//remove implemntation to make it precise
}
但是收到错误
HTTP Status 500 - Request processing failed; nested exception is java.text.ParseException: Unparseable date: "null"
网址部分看起来像这样
http://localhost:8080/hotels/null/0/null/null?location=delhi&dateCheckIn=04%2F07%2F2015+09%3A00&dateCheckOut=04%2F07%2F2015+20%3A00&adults=1