我在Web应用程序中使用带有JPA和JavaScript的Spring MVC(3.x)。 关于使用javascript的文本框自动完成功能的一个问题...
1 - 在DAOImpl层我有
public List<String> getProjectServiceList()
{
Query query = getEntityManager().createQuery("Select DISTINCT
req.projectServiceName from Request req where req.activeInd=1");
List<String> projectServiceList = query.getResultList();
return projectServiceList;
}
2 - 并且在RequestController.java中我已经设置了模型属性projectServiceList
List<String> projectServiceList = getRequestService().getProjectServiceList();
model.addAttribute("projectServiceList", projectServiceList);
3 - 现在在JSP中,我已经在带有foreach标签的选择框中列出了所有结果
<tr>
<td>Project/Service Name</td>
<td><select name="searchBean.projectServiceName" id="searchBean.projectServiceName" >
<option value="">All</option>
<c:forEach items="${projectServiceList}" var="entry">
<option value="${entry}" ${entry == baseBean.searchBean.projectServiceName
? 'selected' : ''}>${entry}</option>
</c:forEach>
</select>
</td>
</tr>
但我的问题是如何使用java脚本(i。使用自动完成文本框) 在具有所有列表的jsb中具有模型属性'projectServiceList'
答案 0 :(得分:0)
您有两种选择:
这两个解决方案都包含一些可以解决问题的自动完成组件。 想到的两个是: