【发布时间】:2018-01-12 00:38:54
【问题描述】:
这是我的搜索VO
public class SearchVO {
String keyword="default";
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
}
我想在每次单击按钮时设置 SearchVO 值。
<div class="wrap bordWrap">
<form commandName="SearchVO" id="appList" name="appList"
action="/index2.do" method="post">
First name: <input type="text" name="fname">
<br>
Last name: <input type="text" name="lname">
<br>
<td colspan="5"><input type="text" class="appNameID" title=""
value="${SearchVO.keyword} " name="searchKeyword" placeholder="ID 또는 앱 이름을 입력하세요." /></td>
<p>
<button value="Search" onclick="formSubmit()">검색</button>
</p>
</form>
</div>
我是否可以将 commnadName 设置为 searchVo 并设置搜索关键字?
我的问题是我应该从控制器中获取值吗?'
@RequestMapping("/index2.do")
public String list(ModelMap model,HttpServletRequest request,
@ModelAttribute("SearchVo")SearchVO searchVo){
System.out.println("index2");
System.out.println(searchVo.getKeyword());
System.out.println(request.getAttribute("searchKeyword"));
return "index";
}
【问题讨论】: