100分求一个jquery+Struts2做的一个查询功能 要求有具体代码,越详细越好,请各位大哥大姐有话的给小弟贴出来,谢谢了,非常感谢,万分感谢!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你一个1.数据库表结构(mysql数据库) 1)建表语句: CREATE TABLE catlog ( catlogid int(11) NOT NULL AUTO_INCREMENT, catlogname varchar(20) NOT NULL, mainBook text, supplyCompany text, amount int(11), PRIMARY KEY USING BTREE (catlogid) ) ENGINE= InnoDB DEFAULT CHARSET= utf8 2)表中数据为: 1 computer 操作系统、java开发、数据库技术 北京图书印刷公司 100 2 ecnomic 宏观经济、微观经济、市场营销 人民邮电出版社 200 3 life 浮沉 新华书店 300 2.jsp页面为: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib prefix="ww" uri="/webwork" %><% String webapp=request.getContextPath(); %><html> <head> <link href="<%=webapp%>/etc/css/common.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <SCRIPT language="javascript" src="<%=webapp%>/etc/js/jquery.js"></SCRIPT> <title>网络书城</title> <script type="text/javascript"> function setValue(){ // document.getElementById("detail").style="visibility:visible ;" $('#list').show(); $('#mainBook').attr("value","${catalog.mainBook}"); $('#supplyCompany').attr("value","${catalog.supplyCompany}"); $('#amount').attr("value","${catalog.amount}"); } function viewDetail(name){ $.getJSON( "getCatalogInfo.action", { catalogName: name }, function(msg){ $('#mainBook').attr("value",msg.mainBook); $('#supplyCompany').attr("value",msg.supplyCompany); $('#amount').attr("value",msg.amount); } ); } </script> </head> <body> <div id="ajax" class="list" style="display:block"> <form id="frm" action="getCatalogInfo.action"> <table > <tr> <td>请选择图书种类: <select onchange="viewDetail(this[selectedIndex].text)"> <ww:iterator id="catalogList" value="catalogList"> <option value="${catlogname}">${catlogname} </option> </ww:iterator> </select> </td> </tr> </table> <table> <tr><td>主要图书:<input id="mainBook" type="text" value=""/></td></tr> <tr><td>主要供应商:<input id="supplyCompany" type="text" value=""/></td></tr> <tr><td>本书店拥有该图书数量:<input id="amount" type="text" value=""/></td></tr> </table> </form> </div> </body></html>3.action代码 public String getCatalogInfo(){ catalog=ICatalogService.getCatlogByName(catalogName); JSONObject json= new JSONObject(); try { json.put("mainBook",catalog.getMainBook()); json.put("supplyCompany", catalog.getSupplyCompany()); json.put("amount", catalog.getAmount()); } catch (JSONException e) { e.printStackTrace(); return ERROR; } catalogName = json.toString(); return SUCCESS; }4.service层代码: public Catlog getCatlogByName(String name) { return ICatalogDAO.getCatlog(name); } 5.pojo package cn.resoft.cm.vo;import java.util.HashSet;import java.util.Set;public class Catlog implements java.io.Serializable { private Integer catlogid; private String catlogname; private String mainBook; private String supplyCompany; private Integer amount; private Set books = new HashSet(0); public Catlog() { } public Catlog(String catlogname) { this.catlogname = catlogname; } public Catlog(String catlogname, Set books) { this.catlogname = catlogname; this.books = books; } public Integer getCatlogid() { return this.catlogid; } public void setCatlogid(Integer catlogid) { this.catlogid = catlogid; } public String getCatlogname() { return this.catlogname; } public void setCatlogname(String catlogname) { this.catlogname = catlogname; } public Set getBooks() { return this.books; } public void setBooks(Set books) { this.books = books; } public String getMainBook() { return mainBook; } public void setMainBook(String mainBook) { this.mainBook = mainBook; } public String getSupplyCompany() { return supplyCompany; } public void setSupplyCompany(String supplyCompany) { this.supplyCompany = supplyCompany; } public Integer getAmount() { return amount; } public void setAmount(Integer amount) { this.amount = amount; }} 对象的创建之方法和属性的调用【太诡异了?】 求救:字符串分割问题,头疼 为什么没有Java专用的CPU? java 对象数组取值 用DatagramPacket发送数据最快能到什么程度? 飞鱼在线编辑器报错!!!急!~~ 请教:如何获取文件存储编码格式 关于ajax的问题 帮我看看怎么样引用没有打包的类 对我来说,生死相关的问题请大家指点为盼!!!!!! 在后台运行java程序,开war3.exe之后,就不能用runTime.exec()了 简单多线程问题
1.数据库表结构(mysql数据库) 1)建表语句: CREATE
TABLE catlog
(
catlogid int(11) NOT NULL AUTO_INCREMENT,
catlogname varchar(20) NOT NULL,
mainBook text,
supplyCompany text,
amount int(11),
PRIMARY KEY USING BTREE (catlogid)
)
ENGINE= InnoDB DEFAULT CHARSET= utf8
2)表中数据为: 1 computer 操作系统、java开发、数据库技术 北京图书印刷公司 100
2 ecnomic 宏观经济、微观经济、市场营销 人民邮电出版社 200
3 life 浮沉 新华书店 300 2.jsp页面为: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="ww" uri="/webwork" %>
<% String webapp=request.getContextPath(); %>
<html>
<head>
<link href="<%=webapp%>/etc/css/common.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<SCRIPT language="javascript" src="<%=webapp%>/etc/js/jquery.js"></SCRIPT>
<title>网络书城</title>
<script type="text/javascript">
function setValue(){
// document.getElementById("detail").style="visibility:visible ;"
$('#list').show();
$('#mainBook').attr("value","${catalog.mainBook}");
$('#supplyCompany').attr("value","${catalog.supplyCompany}");
$('#amount').attr("value","${catalog.amount}");
}
function viewDetail(name){
$.getJSON(
"getCatalogInfo.action",
{ catalogName: name },
function(msg){
$('#mainBook').attr("value",msg.mainBook);
$('#supplyCompany').attr("value",msg.supplyCompany);
$('#amount').attr("value",msg.amount);
}
);
}
</script>
</head>
<body>
<div id="ajax" class="list" style="display:block">
<form id="frm" action="getCatalogInfo.action">
<table >
<tr>
<td>请选择图书种类:
<select onchange="viewDetail(this[selectedIndex].text)">
<ww:iterator id="catalogList" value="catalogList">
<option value="${catlogname}">${catlogname} </option>
</ww:iterator>
</select>
</td>
</tr>
</table>
<table>
<tr><td>主要图书:<input id="mainBook" type="text" value=""/></td></tr>
<tr><td>主要供应商:<input id="supplyCompany" type="text" value=""/></td></tr>
<tr><td>本书店拥有该图书数量:<input id="amount" type="text" value=""/></td></tr>
</table>
</form>
</div>
</body>
</html>
3.action代码
public String getCatalogInfo(){
catalog=ICatalogService.getCatlogByName(catalogName);
JSONObject json= new JSONObject();
try {
json.put("mainBook",catalog.getMainBook());
json.put("supplyCompany", catalog.getSupplyCompany());
json.put("amount", catalog.getAmount());
} catch (JSONException e) {
e.printStackTrace();
return ERROR;
}
catalogName = json.toString();
return SUCCESS;
}
4.service层代码:
public Catlog getCatlogByName(String name) {
return ICatalogDAO.getCatlog(name);
}
5.pojo package cn.resoft.cm.vo;
import java.util.HashSet;
import java.util.Set;
public class Catlog implements java.io.Serializable {
private Integer catlogid;
private String catlogname;
private String mainBook;
private String supplyCompany;
private Integer amount;
private Set books = new HashSet(0);
public Catlog() {
}
public Catlog(String catlogname) {
this.catlogname = catlogname;
}
public Catlog(String catlogname, Set books) {
this.catlogname = catlogname;
this.books = books;
}
public Integer getCatlogid() {
return this.catlogid;
}
public void setCatlogid(Integer catlogid) {
this.catlogid = catlogid;
}
public String getCatlogname() {
return this.catlogname;
}
public void setCatlogname(String catlogname) {
this.catlogname = catlogname;
}
public Set getBooks() {
return this.books;
}
public void setBooks(Set books) {
this.books = books;
}
public String getMainBook() {
return mainBook;
}
public void setMainBook(String mainBook) {
this.mainBook = mainBook;
}
public String getSupplyCompany() {
return supplyCompany;
}
public void setSupplyCompany(String supplyCompany) {
this.supplyCompany = supplyCompany;
}
public Integer getAmount() {
return amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
}