百度模糊修改

 
 
%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
**
-----------------JS页面----------------------
**
var xmlhttp;
function getIE(){
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveObject("Microsoft.XMLHTTP");
}
}
//动作
function getqiwu(obj){
getIE();
var t=obj.value;
if(t.length>0){
var url="${pageContext.request.contextPath}/part_all.action?Pname="+t;
var myurl=encodeURI(url);
xmlhttp.open("post",myurl,true);
xmlhttp.send();
xmlhttp.onreadystatechange=getBack;
}else{
document.getElementById("x").innerHTML="";
}
}
function getBack(){
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById("x").innerHTML=xmlhttp.responseText;
}
}
//点击改行,上去了并消失
function getA(obj){
document.getElementById("name").value=obj.innerHTML;
document.getElementById("x").innerHTML="";
}
**
------------------Action--------------------
**
package com.qw.action;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.sound.midi.MidiDevice.Info;
import org.apache.struts2.ServletActionContext;
import com.qw.entity.TPart;
import com.qw.service.PartService;
public class PartAction {
private PartService service=null;
private String PName;
public PartService getService() {
return service;
}
public void setService(PartService service) {
this.service = service;
}
public String getPname() {
return PName;
}
public void setPname(String pname) {
PName = pname;
}
public String all(){
try {
String xPName=new String(PName.getBytes("ISO8859_1"),"utf-8");
System.out.println(PName+"--------------");
List ar=this.service.getAllLike(xPName);
HttpServletResponse response=ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
out.print("<table>");
for (int i = 0; i < ar.size(); i++) {
System.out.println(ar.size()+"asasasasa");
TPart part=(TPart) ar.get(i);
out.print("<tr><td οnclick='getA(this)'>"+part.getPName()+"</td></tr>");
}
out.print("</table>");
out.flush();
out.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
}
-----------------DAO------------------------
//模糊部门查询
public List getLike(final String PName){
return this.getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
// TODO Auto-generated method stub
return session.createQuery("from TPart a where a.PName like ?").setString(0, '%'+PName+'%').list();
}
});
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值