首页上一页 1 下一页尾页 1 条记录 1/1页
JSP项目开发全程实录中第五章企业资源管理 想根据人名搜索只支持英文字符不支持中文字符 如何修改?
发表在JavaWeb图书答疑
2012-04-21
是否精华
是
否
版块置顶:
是
否
根据项目改写,想添加搜索功能,但只支持英文字符搜索不支持中文搜索。如何修改?以下为相关代码
jsp:
<td>请输入需查询的客户姓名:</td>
<td><input type="text" name="cname" value="<%=resultcname%>"></td>
<td><input name="sumbit1" type="submit" value="查询"></td>
Action:
public ActionForward queryCustomer(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List list = objectDao
.getObjectList("from CustomerForm order by id asc");
if(request.getParameter("cname")!=null){
String cname= request.getParameter("cname");
list = objectDao.getObjectList("from CustomerForm where cname like'%"+cname+"%'");
if(list == null || list.isEmpty()){
request.setAttribute("result","未查询到相关数据");
return mapping.findForward("errorCustomer");
}else{
request.setAttribute("resultcname",cname);
}
}
request.setAttribute("list", list);
return mapping.findForward("queryCustomer");
}
jsp:
<td>请输入需查询的客户姓名:</td>
<td><input type="text" name="cname" value="<%=resultcname%>"></td>
<td><input name="sumbit1" type="submit" value="查询"></td>
Action:
public ActionForward queryCustomer(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List list = objectDao
.getObjectList("from CustomerForm order by id asc");
if(request.getParameter("cname")!=null){
String cname= request.getParameter("cname");
list = objectDao.getObjectList("from CustomerForm where cname like'%"+cname+"%'");
if(list == null || list.isEmpty()){
request.setAttribute("result","未查询到相关数据");
return mapping.findForward("errorCustomer");
}else{
request.setAttribute("resultcname",cname);
}
}
request.setAttribute("list", list);
return mapping.findForward("queryCustomer");
}