【发布时间】:2016-01-19 07:06:26
【问题描述】:
@RequestMapping(value= "/search")
public String personList(@ModelAttribute("employee") Employee e,ModelMap map,@RequestParam("drop") String value)
{
/*System.out.println("In Controller " + e.getEmployeeName() +" "+ value);*/
map.put("drop",value);
map.put("employee",e);
map.put("employeeList", employeeService.employeeList(e.getEmployeeName(),value));
return "ViewPage";
}
以上是我的控制器代码
<form:form action="search.html" modelAttribute="employee" method="POST">
<select id="ViewByName" class ="dropdown" name= "drop">
<!-- <option value="r">Select....</option> -->
<option value="s">Starts With</option>
<option value="c">Consist Of</option>
<option value="e">Ends With</option>
</select>
<div id="search-inner">
<td>
<form:input path="employeeName" type="text" name="search" maxlength="30" id="searchfield" title="searchfield" value="type the name of employee to search..." class = "search"
onfocus="if (this.value=='type the name of employee to search...') this.value=''"
onblur="if (this.value == '') this.value ='type the name of employee to search...'"/>
<input type="submit" name="Search" value="Name Search" title="Search" />
</td>
</div>
</form:form>
以上是我的 JSP 页面代码。 我的问题是,当我从下拉列表中选择某个选项并在搜索后根据下拉值输入文本条目搜索时,我的输入字段转到默认文本,但我想将其保留在搜索结果页面中。
【问题讨论】:
-
所有值都没有进入页面或部分?
-
一切正常,但进入搜索页面后输入文本框将重置为默认值,即在搜索页面中键入要搜索的员工姓名...
-
您的“值”默认设置会导致问题。
-
没错,但我应该在哪里修复代码中的错误
-
请检查答案。
标签: javascript java spring