いくつかのエンティティの検索の実現に問題があります。検索の実現により、クライアントから送信されたエラー要求が構文的に間違っていた
タイプステータスレポート
メッセージ
説明クライアントから送信されたリクエストが文法的に間違っていた - Tomcatは400ステータスHTTP私に与えます。
申し訳ございませんが簡単なエラーです。私は初心者です。すべてありがとうございました。
コントローラコード
@RequestMapping(value = "/deputeAppealSearchPageResult", method = RequestMethod.GET)
public String resultOfSearchingDeputeAppeal(@ModelAttribute("appealForRequest")DeputeAppealForRequestDto deputeAppealForRequestDto, Model model){
LOGGER.debug("Receive request to get searching Depute Appeals list");
List<DeputeAppeal>deputeAppealList = deputeAppealService.individualSearch(deputeAppealForRequestDto);
model.addAttribute("deputeAppealList", deputeAppealList);
return "deputeAppealView/deputeAppealSearchPageResult";
}
サービスコード
public List<DeputeAppeal> individualSearch(DeputeAppealForRequestDto deputeAppealForRequestDto) {
RequestForDeputeAppealSearch requestForDeputeAppealSearch = new RequestForDeputeAppealSearch();
SimpleDateFormat format = new SimpleDateFormat("mm-dd-yyyy");
java.sql.Date incomeDateForDeputeAppealSQLSearch;
java.sql.Date outDateForDeputeAppealSQLSearch;
if(deputeAppealForRequestDto.getOutDate() == "") {
deputeAppealForRequestDto.setOutDate(null);
} else {
try {
Date outDateForSearch = format.parse(deputeAppealForRequestDto.getOutDate());
outDateForDeputeAppealSQLSearch = new java.sql.Date(outDateForSearch.getTime());
requestForDeputeAppealSearch.setOutDate(outDateForDeputeAppealSQLSearch);
} catch (ParseException e) {
e.printStackTrace();
}
}
if(deputeAppealForRequestDto.getIncomingDate() == "") {
deputeAppealForRequestDto.setIncomingDate(null);
} else {
try {
Date incomingDateForSearch = format.parse(deputeAppealForRequestDto.getIncomingDate());
incomeDateForDeputeAppealSQLSearch = new java.sql.Date(incomingDateForSearch.getTime());
requestForDeputeAppealSearch.setIncomingDate(incomeDateForDeputeAppealSQLSearch);
} catch (ParseException e) {
e.printStackTrace();
}
}
requestForDeputeAppealSearch.setOutNumber(deputeAppealForRequestDto.getOutNumber());
requestForDeputeAppealSearch.setIncomeNumber(deputeAppealForRequestDto.getIncomeNumber());
requestForDeputeAppealSearch.setNameAndAddressOfApplicant(deputeAppealForRequestDto.getNameAndAddressOfApplicant());
requestForDeputeAppealSearch.setNameOfDepute(deputeAppealForRequestDto.getNameOfDepute());
requestForDeputeAppealSearch.setSendingOrganization(deputeAppealForRequestDto.getSendingOrganization());
requestForDeputeAppealSearch.setShortContentOfAppeal(deputeAppealForRequestDto.getShortContentOfAppeal());
requestForDeputeAppealSearch.setMainWorker(deputeAppealForRequestDto.getMainWorker());
requestForDeputeAppealSearch.setTypeOfDeputeAppeal(deputeAppealForRequestDto.getTypeOfDeputeAppeal());
return deputeAppealDao.individualSearch(requestForDeputeAppealSearch);
}
DAOコード
public List<DeputeAppeal> individualSearch(RequestForDeputeAppealSearch deputeAppealForRequest) {
Criteria criteria = sessionDao.getSession().createCriteria(DeputeAppeal.class);
if(!deputeAppealForRequest.getOutNumber().equals("")) {
criteria.add(Restrictions.eq("outNumber", deputeAppealForRequest.getOutNumber()));
}
if(deputeAppealForRequest.getIncomeNumber() != 0) {
criteria.add(Restrictions.eq("incomeNumber", deputeAppealForRequest.getIncomeNumber()));
}
if(!deputeAppealForRequest.getNameAndAddressOfApplicant().equals("")) {
criteria.add(Restrictions.like("nameAndAddressOfApplicant", deputeAppealForRequest.getNameAndAddressOfApplicant()));
}
if(!deputeAppealForRequest.getNameOfDepute().equals("")) {
criteria.add(Restrictions.like("nameOfDepute", deputeAppealForRequest.getNameOfDepute()));
}
if(!deputeAppealForRequest.getSendingOrganization().equals("")) {
criteria.add(Restrictions.eq("sendingOrganization", deputeAppealForRequest.getSendingOrganization()));
}
if(deputeAppealForRequest.getOutDate() != null) {
criteria.add(Restrictions.eq("outDate", deputeAppealForRequest.getOutDate()));
}
if(deputeAppealForRequest.getIncomingDate() != null) {
criteria.add(Restrictions.eq("incomingDate", deputeAppealForRequest.getIncomingDate()));
}
if(!deputeAppealForRequest.getShortContentOfAppeal().equals("")) {
criteria.add(Restrictions.like("shortContentOfAppeal", deputeAppealForRequest.getShortContentOfAppeal()));
}
if(deputeAppealForRequest.getTypeOfDeputeAppeal() != null) {
criteria.add(Restrictions.eq("typeOfDeputeAppeal", deputeAppealForRequest.getTypeOfDeputeAppeal()));
}
if(!deputeAppealForRequest.getMainWorker().equals("")) {
criteria.add(Restrictions.eq("mainWorker", deputeAppealForRequest.getMainWorker()));
}
return criteria.list();
}
JSP
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<title>Пошук запитів (звернень) народних депутатів</title>
<head>
<meta charset="utf-8">
<!-- Jquery -->
<script src="../../../resources/bootstrap/jquery/jquery-2.2.2.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="../../../resources/bootstrap/js/bootstrap.js"></script>
<link href="<c:url value="/resources/bootstrap/css/bootstrap.css" />" rel="stylesheet">
<link href="<c:url value="/resources/styles/deputeAppealPagesStyle/deputeAppealSearchPage.css" />" rel="stylesheet">
</head>
<body>
<div class="container head">
<a href="/main/Menu"><img class="header" src="../../../resources/images/police.png"></a>
</div>
<c:url var="getDeputeAppeals" value="/deputeAppeal/deputeAppealSearchPageResult"/>
<form:form method="get" action="${getDeputeAppeals}">
<div class="container">
<div class="row main">
<div class="col-md-4 left_block">
<label>Номер вих.</label>
<input type="text" id="outNumber" class="form-control" name="outNumber" path="outNumber">
<label>Номер вх.</label>
<input type="text" id="incomeNumber" class="form-control" name="incomeNumber" path="incomeNumber">
<label>Дата вх.</label>
<input type="date" id="incomingDate" class="form-control" name="incomingDate" path="incomingDate">
<label>Дата вих.</label>
<input type="date" id="outDate" class="form-control" name="outDate" path="outDate">
<label>П.І.Б та адреса заявника</label>
<input type="text" id="nameAndAddressOfApplicant" class="form-control" name="nameAndAddressOfApplicant" path="nameAndAddressOfApplicant">
</div>
<div class="col-md-4 right_block">
<label>П.І.Б народного депутата</label>
<input type="text" id="nameOfDepute" class="form-control" name="nameOfDepute" path="nameOfDepute">
<label>Інстанція з якої надійшов документ</label>
<input type="text" id="sendingOrganization" class="form-control" name="sendingOrganization" path="sendingOrganization">
<label>Короткий зміст</label>
<textarea id="shortContentOfAppeal" class="form-control" name="shortContentOfAppeal" path="shortContentOfAppeal"></textarea>
<label>Вид</label>
<select class="form-control" id="typeOfDeputeAppeal" name="TypeOfDeputeAppeal" path="TypeOfDeputeAppeal">
<option disabled selected value>blank</option>
<option value="Звернення">Звернення</option>
<option value="Запит">Запит</option>
</select>
<label>Служба виконавець</label>
<textarea class="form-control" id="mainWorker" name="mainWorker" path="mainWorker"></textarea>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-offset-4 col-md-4 col-md-offset-4">
<p id="message"></p>
<button type="submit" class="btn btn-primary">Пошук</button>
</div>
</div>
</div>
</form:form>
</body>
</html>
DOMAINコード
public class DeputeAppealForRequestDto extends RequestDto {
private String outNumber;
private int incomeNumber;
private String incomingDate;
private String outDate;
private String nameAndAddressOfApplicant;
private String nameOfDepute;
private String sendingOrganization;
private String shortContentOfAppeal;
private String mainWorker;
private String typeOfDeputeAppeal;
public DeputeAppealForRequestDto() {}
public String getOutNumber() {
return outNumber;
}
public void setOutNumber(String outNumber) {
this.outNumber = outNumber;
}
public String getNameOfDepute() {
return nameOfDepute;
}
public void setNameOfDepute(String nameOfDepute) {
this.nameOfDepute = nameOfDepute;
}
public String getIncomingDate() {
return incomingDate;
}
public void setIncomingDate(String incomingDate) {
this.incomingDate = incomingDate;
}
public String getShortContentOfAppeal() {
return shortContentOfAppeal;
}
public void setShortContentOfAppeal(String shortContentOfAppeal) {
this.shortContentOfAppeal = shortContentOfAppeal;
}
public String getTypeOfDeputeAppeal() {
return typeOfDeputeAppeal;
}
public void setTypeOfDeputeAppeal(String typeOfDeputeAppeal) {
this.typeOfDeputeAppeal = typeOfDeputeAppeal;
}
public String getOutDate() {
return outDate;
}
public void setOutDate(String outDate) {
this.outDate = outDate;
}
public String getNameAndAddressOfApplicant() {
return nameAndAddressOfApplicant;
}
public void setNameAndAddressOfApplicant(String nameAndAddressOfApplicant) {
this.nameAndAddressOfApplicant = nameAndAddressOfApplicant;
}
public String getSendingOrganization() {
return sendingOrganization;
}
public void setSendingOrganization(String sendingOrganization) {
this.sendingOrganization = sendingOrganization;
}
public String getMainWorker() {
return mainWorker;
}
public void setMainWorker(String mainWorker) {
this.mainWorker = mainWorker;
}
public int getIncomeNumber() {
return incomeNumber;
}
public void setIncomeNumber(int incomeNumber) {
this.incomeNumber = incomeNumber;
}
}
投稿のメソッドが変更されましたが、これは役に立ちません –
リクエストマッピングのメソッドも変更しましたか? '@RequestMapping(value ="/deputeAppealSearchPageResult "、method = RequestMethod.POST)' 適切な解決策ではなく、むしろwrokaroundであることに注意してください。 – wcislo
マッピングとJSPでメソッドを変更します。これは問題ではないと私は思う。それがGETとPOSTで動作する前に。他に何かが間違っています –