Обязательный параметр String 'вылет' отсутствует
Мой контроллер:
@RequestMapping(value = "/search", method = RequestMethod.GET)
public String search(
@RequestParam String departure,
@RequestParam String arrival,
@RequestParam String departureTime,
Model model) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
departureTime += " 00:00:00"; // departureTime = departureTime + " 00:00:00";
LocalDateTime date = LocalDateTime.parse(departureTime, formatter);
Iterable<BusFlight> selects = busFlightService.getAll();
List<BusFlight> busflights = busFlightService.search(departure, arrival, date);
if (selects != null && busflights != null) {
model.addAttribute("selects", selects);
model.addAttribute("busflights", busflights);
} else {
model.addAttribute("busflights", "no flights");
}
return "search";
}
Мой шаблон FreeMarker
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"
</head>
<body style="background-color: #138496;">
<form action="/public/search" method="get">
<div class="container" style="margin-top: 200px">
<div class="row">
<p>Click every input.</p>
</div>
<div class="row">
<span>
<select name="departure" class="combobox input-large form-control" style="margin-right: 10px">
<#list selects! as select>
<option value="${select.id}">${select.departure}</option>
</#list>
</select>
</span>
<span>
<select name="arrival" class="combobox input-large form-control">
<#list selects! as select>
<option value="${select.id}">${select.arrival}</option>
</#list>
</select>
</span>
<span>
<input type="date" class="form-control mb-2 mr-sm-2" id="inlineFormInputName2" value="2018-08-20" name="departureTime"/>
</span>
<span>
<button type="button" class="btn btn-primary">Search</button>
</span>
</div>
</div>
<#if busflights??>
<#list busflights as busflight >
<table class="table table-hover table-dark">
<thead>
<tr>
<th scope="col">Departure</th>
<th scope="col">Arrival</th>
<th scope="col">DepartureTime</th>
</tr>
</thead>
<tbody>
<tr>
<td>${busflight.departure}</td>
<td>${busflight.arrival}</td>
<td>${busflight.departureTime}</td>
</tr>
</tbody>
</table>
</#list>
<#else >
No buses
</#if>
</form>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="/static/js/bootstrap-combobox.js"></script>
<script>
$(document).ready(function(){
$('.combobox').combobox()
});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36251023-1']);
_gaq.push(['_setDomainName', 'jqueryscript.net']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
Моя ошибка:
There was an unexpected error (type=Bad Request, status=400).
Required String parameter 'departure' is not present
И еще один вопрос, возможно ли использовать запрос GET для одного сопоставления "/ search" и поместить его в размер клиента?как я пытался в моем случае?
Также, как я могу избавиться от "Обязательный параметр строки 'вылет' нет"
Санкс