0
我想要做的似乎很簡單,但每個配置我用給我下面的錯誤時:如何避免「無論BindingResult也不是爲bean名稱平原目標對象‘命令’可以作爲請求屬性」搜索
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
我想傳遞一個字符串給控制器搜索和Offices
一個List
了在新的頁面中發現的顯示屬性。我無法查看我的瀏覽器中的officeSearch頁面,我收到上述錯誤。
officeSearch.jsp(應該只是一個簡單的形式傳遞一個被搜索的字符串):
<div class="header-divider2">
<h4>Search</h4>
</div>
<div id="content" class="center">
<div class="well center square borderless">
<h1>Location Search</h1>
<div class="visible-md visible-lg well well-search">
<form:form method="POST" action="officeSearchResults">
<div class="form-group">
<form:input path="searchCriteria" type="text" id="searchCriteria" placeholder="Find a location..." />
</div>
<input type="submit" class="btn btn-default" value="Search" />
</form:form>
</div><!-- visible-md -->
</div><!-- well center square -->
</div><!-- center -->
下面是應顯示在搜索頁面的控制方法:
@RequestMapping(value = "/officeSearch", method=RequestMethod.GET)
public String showOfficesSearch() {
return "officeSearch";
}
這裏提交搜索後應顯示的jsp(明顯存在殘留):
<div class="header-divider2">
<h4>Search Results</h4>
</div>
<div id="content" class="center">
<div class="well center square borderless">
<h1>Location Search RESULTS</h1>
</div><!-- well center square -->
</div><!-- center -->
這裏是一個的意思顯示前一頁的控制器方法:
@RequestMapping(value = "/officeSearchResults", method = RequestMethod.POST)
public ModelAndView search(@ModelAttribute("officeSearchResults") String searchCriteria) {
List<Office> offices = officeServiceImpl.search(searchCriteria);
return new ModelAndView("officeSearchResults", "command", offices);
}
在得到這方面的工作,請告知。謝謝。