我有这个控制器:
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class SearchServicesController extends SearchController {
protected void checkSessionAttributes (HttpServletRequest request, HttpServletResponse response, Locale locale ) {
super.checkSessionAttributes(request, response, locale);
}
/**
*
* @param request the http servlet request.
* @param model the spring model.
*
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/services.do", method = RequestMethod.GET)
public String initForm(HttpServletRequest request, HttpServletResponse response, Model model, Locale locale) {
model.addAttribute("deviceStoreForm" , new DeviceStoreForm());
return "servicesSearchView";
}
/**
*
* @param request the http servlet request.
* @param model the spring model.
*
*/
@RequestMapping(value = "/services.do", method = RequestMethod.POST)
public String formSubmission(HttpServletRequest request, HttpServletResponse response,
Model model, Locale locale, DeviceStoreForm deviceStoreForm) {
checkSessionAttributes(request, response, locale);
return "servicesSearchView";
}
}
以及此表格:
<form:form action="/ecat/services.do" method="post" commandName="deviceStoreForm" class="TTWForm1" id="simpleSearchForm">
<div id="sidebar_search">
<input type="hidden" name="availabilityCountriesName" value="" id="availabilityCountriesId" />
<input type="hidden" name="quickSearch" value="" id="quickSearch" />
<input type="hidden" name="normalSearch" value="" id="normalSearch" />
<input type="hidden" name="showDetails" value="" id="showDetails" />
<input type="hidden" name="itemId" value="" id="itemId" />
<input type="hidden" name="locale" value="" id="locale" />
<input name="searchString" size="34" maxlength="255"
onBlur="if(this.value=='')this.value='<fmt:message key="search.by.keyword" />';"
onKeyPress="doClickQuickSearch('submit',event)"
onFocus="if(this.value=='<fmt:message key="search.by.keyword" />')this.value='';"
<c:choose>
<c:when test="${empty searchString}">
value="<fmt:message key="search.by.keyword"/>"
</c:when>
<c:otherwise>
value="${searchString}"
</c:otherwise>
</c:choose>
type="text" />
<input id="" class="buttoninsideform buttoninsidefield" onclick="submitQuickSearch ();" type="button" value="<fmt:message key="search.button"/>" >
<br><br>
<fmt:message key="quick.search.disclaimer" />
</div>
<input type="hidden" name="actionName" value=""/>
<fieldset>
<label class="titlefieldset"><fmt:message key="search.advancedSearch"/></label>
<p class="txtintro" style="margin-left: 10px;"></p>
<div class="field f50">
<label for="">TOURISM SERVICES<span class="therequiredsign"> *</span></label>
<!-- select name="categoriesArray" id="categoriesArrayId" multiple="multiple" size="2" -->
<select name="categoriesArray" id="categoriesArrayId" size="2" >
<c:forEach items="${sessionScope.servicesGroupList}" var="category" >
<option value="${fn:replace(category.key, ',' , ' ')}"
<c:if test='${selectedCategory == category.key}'>
selected="selected"
</c:if>
>${category.description}</option>
</c:forEach>
</select>
</div>
<div class="field f50">
</div>
<div class="field f50">
<label for="">REGION</label>
<select name="regionSelectName" id="regionSelectId" multiple="multiple" size="10">
<c:forEach items="${sessionScope.regionList}" var="region">
<option value="${region.id}" > ${region.name} (${region.countryCode})</option>
</c:forEach>
</select>
</div>
<div class="field f50">
<label for="">CITY</label>
<select name="citySelectName" id="citySelectId" multiple="multiple" size="10">
<c:forEach items="${cityList}" var="city">
<option value="${city}" style="text-transform: capitalize"> ${fn:toLowerCase(city)}</option>
</c:forEach>
</select>
</div>
<div class="simplebr"></div>
<div class="field f100">
<input id="" class="buttoninsideform buttoninsidefield" type="button" value="<fmt:message key="greenstore.search.search.search" />" onclick="javascript:submitNormalSearch();" />
</div>
<div class="simplebrplus10"></div>
</fieldset>
</form:form>
当我在formSubmission函数中添加参数DeviceStoreForm deviceStoreForm时出现问题;然后,当我提交表单时,我在jsp中得到错误400 - 错误请求,我在错误日志或控制台中看不到任何异常