- <dwr>
- <allow>
- <create creator="spring" javascript="DistrictLocationService">
- <param name="beanName" value="districtLocationService" />
- <include method="findAllByLocationRangeFor51ditu" />
- <include method="findAllByKeywords" />
- create>
- <convert converter="bean" match="com.goojia.dal.model.DistrictLocation">
- <param name="include" value="id,districtName,avgPrice,address,houseCount,lng51,lat51">param>
- convert>
- allow>
- dwr>
- service 层查找方法
- /**
- * 根据输入的关键字查询小区信息,最大返回MAX_DISTRICT条记录
- * @param keywords
- * @return
- */
- public List<districtlocationbo></districtlocationbo> findAllByKeywords(String keywords){
- }
前面使用非常简单。只需要把生成的javascript导入 把componet组件放到你想放文本输入框的地方,并设置一下你想使用的样式,如果不传,将使用默认的样式
<script type='text/javascript' src='<ww:url value="/dwr/interface/DistrictLocationService.js" includeParams="none" />'></script>
<script type='text/javascript' src='<ww:url value="/dwr/engine.js" includeParams="none" />'></script>
<script type="text/javascript" src="<ww:property value="picurl"/>js/prototype.js"></script>
<script type="text/javascript" src="<ww:property value="picurl"/>js/autocomplete.js"></script>
- <ww:component id="district" name="districtName" template="autocomplete">
- <ww:param name="size">40ww:param>
- <ww:param name="maxlength">30ww:param>
- <ww:param name="dwrMethod">DistrictLocationService.findAllByKeywordsww:param>
- <ww:param name="hiddenId">'districtId'ww:param>
- ww:component>
本文分享了使用JavaScipt+DWR+Spring+Hibernate实现类似Googlesuggest功能的方法。通过配置DWR将后端服务暴露给前端,前端可以像调用自定义函数一样调用这些服务。
1086

被折叠的 条评论
为什么被折叠?



