- 浏览: 477027 次
- 性别:
- 来自: 南京
-
文章分类
最新评论
-
fkbld:
楼主给个密码,谢谢了,baild_zr@126.com
ExtJs direct 推送 DEMO -
文思涌动:
你的方法太好用了,感激不尽。
MyEclipse 安装ADT -
zys08:
...
jquery uploadify -
攻城使:
我现在也在学习使用Uploadfiy,摸索中
jquery uploadify -
gksrxn:
liuyulovely 写道怎么解压还要密码,楼主解压的密码是 ...
ExtJs direct 推送 DEMO
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
偶的JAVA 随记
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<一>表单 提交 条件 JSP-SERVLET-JSP 获取数据库的信息 返回给控制台
1. JSP
用户的半动态表单
<%@ page language="java" pageEncoding="gbk"%>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.jsp.JspWriter"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script lanaguage="javascript">
function btnQuyu_Onclick(q)
{
if(q.selectedIndex==1){
document.frm.city.style.display = "none";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==2){
document.frm.city.style.display = "";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==3){
document.frm.city.style.display = "";
document.frm.county.style.display = "";
}
}
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array("城北供电公司","=025","=1");//county ,分组,countyID
subcat[1] = new Array("城南供电公司","=025","=2");
subcat[2] = new Array("栖霞供电公司","=025","=3");
subcat[3] = new Array("雨花供电公司","=025","=4");
subcat[4] = new Array("溧水供电公司","=025","=6");
subcat[5] = new Array("高淳供电公司","=025","=7");
subcat[6] = new Array("六合供电公司","=025","=8");
subcat[7] = new Array("浦口供电公司","=025","=9");
subcat[8] = new Array("江宁供电公司","=025","=10");
subcat[9] = new Array("计量中心","=025","=12");
subcat[10] = new Array("镇江分县1","0511","004");
subcat[11] = new Array("镇江分县2","0511","005");
subcat[12] = new Array("镇江分县3","0511","006");
onecount=13;
function changelocation(locationid)
{
document.frm.county.length = 0;
var locationid=locationid;
var i;
document.frm.county.options[0] = new Option('====所有区县====','!=0');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.frm.county.options[document.frm.county.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body>
<form name="frm" action="XxcxServlet" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="6"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="4" cellspacing="1">
<tr align="center" bgcolor="#EBEADB">
<td colspan="5" >详细数据查询</td>
</tr>
<tr>
<td height="14" align="left" >选择时间段:</td>
</tr>
<tr>
<td bgcolor="#f4f4f4" colspan="3">
<select name="year1">
<option>2006</option>
</select>日
</td>
</tr>
<tr bgcolor="#FFFFFF">
</tr>
<tr>
<td>
<select name="quyu" onchange="btnQuyu_Onclick(this);">
<option>==请先选择区域==</option>
<option value="aqs">按全省</option>
<option value="ads">按地市</option>
<option value="aqx">按区县</option>
</select>
</td>
</tr>
<tr bgcolor="#f4f4f4" >
<td>
<!-- 新小知识点 -->
<select name="city" onChange="changelocation(document.frm.city.options[document.frm.city.selectedIndex].value)">
<option value="!=0">==请先选择地市==</option>
<option value="=025">南京</option>
<option value="=0511">镇江</option>
<option value="=0519">常州</option>
<option value="=0516">徐州</option>
<option value="=0512">苏州</option>
<option value="=0510">无锡</option>
<option value="=0513">南通</option>
<option value="=0527">宿迁</option>
<option value="=0514">扬州</option>
<option value="=0523">泰州</option>
<option value="=0517">淮安</option>
<option value="=0515">盐城</option>
<option value="=0518">连云港</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="county">
<option>==所有区县==</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="xxcx">
<option value="!=0">==请选择业务类型==</option>
<option value="!=0">全部</option>
<option value="=1">业务受理</option>
<option value="=2">费用缴纳</option>
<option value="=3">咨询</option>
<option value="=4">查询</option>
<option value="=5">投诉举报</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" value="确定"></td>
</tr>
</table>
</form>
<script LANGUAGE="javascript">
<!--
changelocation(document.frm.city.options[document.frm.city.selectedIndex].value);
//-->
</script>
</body>
</html>
2.
获取数据库中的信息 返回 JSP
Servlet
package com.suypower.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.suypower.bean.XxcxBean;
import com.suypower.db.DBCon;
public class XxcxServlet extends HttpServlet{
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
//获取表单信息
//1。 获取表单 时间 信息
String year1=request.getParameter("year1");
String month1=request.getParameter("month1");
String day1=request.getParameter("day1");
String year2=request.getParameter("year2");
String month2=request.getParameter("month2");
String day2=request.getParameter("day2");
String time1=year1+"-"+month1+"-"+day1;
String time2=year2+"-"+month2+"-"+day2;
System.out.println("时间范围:"+time1+" and "+time2);
//2。城市ID 转换
String cityID=new String(request.getParameter("city").getBytes("iso8859-1"),"GBK");
System.out.println("城市ID:"+cityID);
//3。指标
String xxcxID=new String(request.getParameter("xxcx").getBytes("iso8859-1"),"GBK");
System.out.println("业务类型:"+xxcxID);
//4.county
String countyID=new String(request.getParameter("county").getBytes("iso8859-1"),"GBK");
//String county=request.getParameter("county");
System.out.println("地市ID:"+countyID);
//这里ywl.jsp页面上已经定义了,不用在这里转换了
//5.区域获取
String quyu=new String(request.getParameter("quyu").getBytes("iso8859-1"),"GBK");
System.out.println("选择区域是按:"+quyu);
Connection con=null;
Statement stmt=null;
HttpSession session =request.getSession();
ArrayList array=new ArrayList();
try{
con=new DBCon().getConnection();
String xxcxSQL="select city_id,operation_id,time_start,time_end,result_id2 from pj_evaluate where time_start between '"+time1+"' and '"+time2+"' and city_id"+cityID+" and county_id"+countyID+" and operation_id"+xxcxID+"";
stmt=con.createStatement();
System.out.println("sql:"+xxcxSQL);
ResultSet xxrs=stmt.executeQuery(xxcxSQL);
while(xxrs.next())
{
XxcxBean xb=new XxcxBean();
String mingcheng=xxrs.getString("city_id");
//在这里转换比较好哦
xb.setMingcheng(mingcheng);
String yewuleixing=xxrs.getString("operation_id");
xb.setYewuleixing(yewuleixing);
String pjkssj=xxrs.getString("time_start");
xb.setPjkssj(pjkssj);
String pjjssj=xxrs.getString("time_end");
xb.setPjjssj(pjjssj);
String pjjg=xxrs.getString("result_id2");
xb.setPjjg(pjjg);
array.add(xb);
}
session.setAttribute("array", array);
}catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
{
con.close();
}
}catch(SQLException ee){ee.toString();}
}
//跳转到结果页面
RequestDispatcher rd=request.getRequestDispatcher("xxcx_jg.jsp");
rd.forward(request, response);
}
}
3。最终结果
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import ="java.util.ArrayList" %>
<%@ page import ="com.suypower.bean.XxcxBean" %>
<%@ taglib uri="/WEB-INF/extremecomponents" prefix="ec"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<center>
<table border="4">
<tr>
<td>名称</td><td>业务类型</td><td>评价开始时间</td><td>评价结束时间</td><td>评价结果</td>
</tr>
<tr>
<!-- 使用标签 分页显示 session 中的 信息 -->
<%
ArrayList array=new ArrayList();
array=(ArrayList)session.getAttribute("array");
%>
<%
for(int i=0;i<array.size();i++)
{
%>
<%
XxcxBean xb=new XxcxBean();
xb=(XxcxBean)array.get(i);
String mingcheng=xb.getMingcheng();
String ywlx=xb.getYewuleixing();
String startTime=xb.getPjkssj();
String endTime=xb.getPjjssj();
String suc=xb.getPjjg();
%>
<td><%= mingcheng%></td>
<td><%= ywlx%></td>
<td><%= startTime%></td>
<td><%= endTime%></td>
<td><%= suc%></td>
</tr>
<%
}
%>
</table>
</center>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<二>一个 下拉 动态 读取 数据库
FOR:
1.
package Test;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import DBConnect.DBConn;
public class Bumen {
public void getBumen(HttpServletRequest request,JspWriter out) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
DBConn db = new DBConn();
conn = db.getConnection();
stmt = conn.createStatement();
String sql = "select distinct bm_name from PJ_BM";
rs = stmt.executeQuery(sql);
String html ="";
while (rs.next())
{
String bm_name=rs.getString("bm_name");
out.print("<option>"+bm_name+"</option>");
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
e.getMessage();
}
}
}
}
2.JSP
<td>
<select name="city">
<option>-请选择城市-</option>
<%
Bumen bm=new Bumen();
bm.getBumen(request,out);
%>
</select>
</td>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<三>.
一个简单的柱状报表
后台 获取 数据库的 SQL 信息 放到 SESSION
前台 显示
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="org.jfree.chart.ChartFactory,
java.awt.Color,
java.awt.Font,
org.jfree.chart.JFreeChart,
org.jfree.chart.axis.ValueAxis,
org.jfree.chart.labels.StandardCategoryItemLabelGenerator,
org.jfree.chart.plot.CategoryPlot,
org.jfree.chart.plot.PlotOrientation,
org.jfree.chart.renderer.category.*,
org.jfree.chart.servlet.ServletUtilities,
org.jfree.data.category.CategoryDataset,
org.jfree.data.category.DefaultCategoryDataset" %>
<html>
<body>
<%
String category="江苏营业厅";
double NJhushu=Double.parseDouble(session.getAttribute("NJhushu").toString());
double SZhushu=Double.parseDouble(session.getAttribute("SZhushu").toString());
double WXhushu=Double.parseDouble(session.getAttribute("WXhushu").toString());
double CZhushu=Double.parseDouble(session.getAttribute("CZhushu").toString());
double YZhushu=Double.parseDouble(session.getAttribute("YZhushu").toString());
double NThushu=Double.parseDouble(session.getAttribute("NThushu").toString());
double SQhushu=Double.parseDouble(session.getAttribute("SQhushu").toString());
double XZhushu=Double.parseDouble(session.getAttribute("XZhushu").toString());
double HAhushu=Double.parseDouble(session.getAttribute("HAhushu").toString());
double ZJhushu=Double.parseDouble(session.getAttribute("ZJhushu").toString());
double TZhushu=Double.parseDouble(session.getAttribute("TZhushu").toString());
double YChushu=Double.parseDouble(session.getAttribute("YChushu").toString());
double LYGhushu=Double.parseDouble(session.getAttribute("LYGhushu").toString());
CategoryDataset dataset=this.getDataSet(NJhushu,SZhushu,WXhushu,CZhushu,YZhushu,NThushu,SQhushu,XZhushu,HAhushu,ZJhushu,TZhushu,YChushu,LYGhushu);
String title=category+"受理户数总工号";
JFreeChart chart = ChartFactory.createBarChart3D
(
title,
"城市",
"申请户数",
dataset,
PlotOrientation.VERTICAL,
true,
false,
false
);
String filename = ServletUtilities.saveChartAsPNG(chart,750,350, null, session);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
<P ALIGN="CENTER">
<img src="<%= graphURL %>" width=750 height=350 border=0 usemap="#<%= filename %>">
</P>
<%!
public static CategoryDataset getDataSet(double NJhushu,double SZhushu,double WXhushu,double CZhushu,double YZhushu,double NThushu,double SQhushu,double XZhushu,double HAhushu,double ZJhushu,double TZhushu,double YChushu,double LYGhushu)
{
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(NJhushu,"南京","南京");
dataset.addValue(SZhushu, "苏州", "苏州");
dataset.addValue(WXhushu, "无锡", "无锡");
dataset.addValue(CZhushu, "常州", "常州");
dataset.addValue(YZhushu, "扬州", "扬州");
dataset.addValue(NThushu, "南通", "南通");
dataset.addValue(SQhushu, "宿迁", "宿迁");
dataset.addValue(XZhushu, "徐州", "徐州");
dataset.addValue(HAhushu, "淮安", "淮安");
dataset.addValue(ZJhushu, "镇江", "镇江");
dataset.addValue(TZhushu, "泰州", "泰州");
dataset.addValue(YChushu, "盐城", "盐城");
dataset.addValue(LYGhushu, "连云港", "连云港");
return dataset;
}
%>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<四>.动态显示数据 导出报表 SQL 读取 到 BEAN 中 这里用的SQL是子查询 全部写入
FOR:
SQL=select a.county_id,a.county_name,
(select count(b.yw_zhh) from pj_yxyw b where b.county_id = a.county_id) as county_zhh,
(select abs(sum(cast(b.yw_rl as int))) from pj_yxyw b where b.county_id = a.county_id)as county_rl,
(select count(c.dfsf_zhh) from pj_yxdfsf c where c.county_id = a.county_id) as county_dfsf_zhh,
(select sum(cast(c.dfsf_je as decimal(35,2))) from pj_yxdfsf c where c.county_id = a.county_id)as county_dfsf_je,
(select count(d.ywsf_zhh) from pj_yxywsf d where d.county_id=a.county_id)as county_ywsf_zhh,
(select sum(cast(e.ywsf_je as decimal(35,2))) from pj_yxywsf e where e.county_id = a.county_id)as county_ywsf_je,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='1') as county_my,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='3') as county_bmy,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='2') as county_yb,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='0') as county_wpj
from pj_county a where a.city_id='"+cityID+"'
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="org.jfree.chart.ChartFactory,
java.awt.Color,
java.awt.Font,
org.jfree.chart.JFreeChart,
org.jfree.chart.axis.ValueAxis,
org.jfree.chart.labels.StandardCategoryItemLabelGenerator,
org.jfree.chart.plot.CategoryPlot,
org.jfree.chart.plot.PlotOrientation,
org.jfree.chart.renderer.category.*,
org.jfree.chart.servlet.ServletUtilities,
org.jfree.data.category.CategoryDataset,
org.jfree.data.category.DefaultCategoryDataset" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.suypower.bean.YwlBean" %>
<html>
<body>
<%
CategoryDataset dataset;
String category="营业厅";
ArrayList array=new ArrayList();
array=(ArrayList)session.getAttribute("array");
dataset=this.getDataSet(array);
String title=category+"受理总工号统计";
JFreeChart chart = ChartFactory.createBarChart3D(title,
"区县",
"受理总工号统计",
dataset,
PlotOrientation.VERTICAL,
true,
false,
false);
String filename = ServletUtilities.saveChartAsPNG(chart,750, 480, null, session);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
<P ALIGN="CENTER">
<img src="<%= graphURL %>" border=0 usemap="#<%= filename %>">
</P>
<%!public static CategoryDataset getDataSet(ArrayList array)
{
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for(int i=0;i<array.size();i++)
{
YwlBean yb=(YwlBean)array.get(i);
System.out.println("城市名字"+yb.getCounty_name()+","+"户数"+yb.getCounty_zhh()+"");
dataset.addValue(Double.parseDouble(yb.getCounty_zhh().toString()),yb.getCounty_name().toString(),yb.getCounty_name().toString());
}
return dataset;
}%>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<六>
1.分页组件 extremecomponents 使用 规范 JSP 用到图片 table images 和 JAR ,TLD
<%@ page language="java" pageEncoding="gbk"%>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.jsp.JspWriter"%>
<%@ taglib uri="/WEB-INF/extremecomponents" prefix="ec"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script lanaguage="javascript">
function btnQuyu_Onclick(q)
{
if(q.selectedIndex==1){
document.frm.city.style.display = "none";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==2){
document.frm.city.style.display = "";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==3){
document.frm.city.style.display = "";
document.frm.county.style.display = "";
}
}
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array("城北供电公司","=025","=1");//county ,分组,countyID
subcat[1] = new Array("城南供电公司","=025","=2");
subcat[2] = new Array("栖霞供电公司","=025","=3");
subcat[3] = new Array("雨花供电公司","=025","=4");
subcat[4] = new Array("溧水供电公司","=025","=6");
subcat[5] = new Array("高淳供电公司","=025","=7");
subcat[6] = new Array("六合供电公司","=025","=8");
subcat[7] = new Array("浦口供电公司","=025","=9");
subcat[8] = new Array("江宁供电公司","=025","=10");
subcat[9] = new Array("计量中心","=025","=12");
subcat[10] = new Array("镇江分县1","=0511","004");
subcat[11] = new Array("镇江分县2","=0511","005");
subcat[12] = new Array("镇江分县3","=0511","006");
onecount=13;
function changelocation(locationid)
{
document.frm.county.length = 0;
var locationid=locationid;
var i;
document.frm.county.options[0] = new Option('====所有区县====','!=0');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.frm.county.options[document.frm.county.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
function showtable()
{
document.frm.change.value="change";
frm.submit();
}
</script>
</head>
<body>
<form name="frm" action="XxcxServlet" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="6"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="4" cellspacing="1">
<tr align="center" bgcolor="#EBEADB">
<td colspan="5" >详细数据查询</td>
</tr>
<tr>
<td height="14" align="left" >选择时间段:</td>
</tr>
<tr>
</select>日
</td>
</tr>
<tr bgcolor="#FFFFFF">
</tr>
<tr>
<td>
<select name="quyu" onchange="btnQuyu_Onclick(this);">
<option>==请先选择区域==</option>
<option value="aqs">按全省</option>
<option value="ads">按地市</option>
<option value="aqx">按区县</option>
</select>
</td>
</tr>
<tr bgcolor="#f4f4f4" >
<td>
<!-- 新小知识点 -->
<select name="city" onChange="changelocation(document.frm.city.options[document.frm.city.selectedIndex].value)">
<option value="!=0">==请先选择地市==</option>
<option value="=025">南京</option>
<option value="=0511">镇江</option>
<option value="=0519">常州</option>
<option value="=0516">徐州</option>
<option value="=0512">苏州</option>
<option value="=0510">无锡</option>
<option value="=0513">南通</option>
<option value="=0527">宿迁</option>
<option value="=0514">扬州</option>
<option value="=0523">泰州</option>
<option value="=0517">淮安</option>
<option value="=0515">盐城</option>
<option value="=0518">连云港</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="county">
<option>==所有区县==</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="xxcx">
<option value="!=0">==请选择业务类型==</option>
<option value="!=0">全部</option>
<option value="=1">业务受理</option>
<option value="=2">费用缴纳</option>
<option value="=3">咨询</option>
<option value="=4">查询</option>
<option value="=5">投诉举报</option>
</select>
</td>
</tr>
<tr>
<td><input type="button" value="确定" onclick="showtable()">
<input type="hidden" name="change">
</td>
</tr>
</table>
<div align="center" id="cz" >
<ec:table
action="${pageContext.request.contextPath}/XxcxServlet"
items="array"
var="a"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
width="99%"
tableId="resultTable1"
rowsDisplayed="10"
form="frm"
filterable="false"
sortable="false"
autoIncludeParameters="false">
<ec:row>
<ec:column property="mingcheng" title="【名称】" width="10%"></ec:column>
<ec:column property="yewuleixing" title="【业务类型】" width="15%"></ec:column>
<ec:column property="pjkssj" title="【评价开始时间】" width="25%"></ec:column>
<ec:column property="pjjssj" title="【评价结束时间】" width="25%"></ec:column>
<ec:column property="pjjg" title="【评价结果】" width="20%"></ec:column>
</ec:row>
</ec:table>
</div>
</form>
<script LANGUAGE="javascript">
<!--
changelocation(document.frm.city.options[document.frm.city.selectedIndex].value);
//-->
</script>
</body>
</html>
2.
SERVLET
package com.suypower.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.suypower.bean.XxcxBean;
import com.suypower.db.DBCon;
public class XxcxServlet extends HttpServlet{
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
//获取表单信息
//1。 获取表单 时间 信息
String year1=request.getParameter("year1");
String month1=request.getParameter("month1");
String day1=request.getParameter("day1");
String year2=request.getParameter("year2");
String month2=request.getParameter("month2");
String day2=request.getParameter("day2");
String time1=year1+"-"+month1+"-"+day1;
String time2=year2+"-"+month2+"-"+day2;
System.out.println("时间范围:"+time1+" and "+time2);
//2。城市ID 转换
String cityID=new String(request.getParameter("city").getBytes("iso8859-1"),"GBK");
System.out.println("城市ID:"+cityID);
//3。指标
String xxcxID=new String(request.getParameter("xxcx").getBytes("iso8859-1"),"GBK");
System.out.println("业务类型:"+xxcxID);
//4.county
String countyID=new String(request.getParameter("county").getBytes("iso8859-1"),"GBK");
//String county=request.getParameter("county");
System.out.println("地市ID:"+countyID);
//这里ywl.jsp页面上已经定义了,不用在这里转换了
//5.区域获取
//--------------------------------------------------------------------------------//
String change=request.getParameter("change");
//--------------------------------------------------------------------------------//
String quyu=new String(request.getParameter("quyu").getBytes("iso8859-1"),"GBK");
System.out.println("选择区域是按:"+quyu);
Connection con=null;
Statement stmt=null;
HttpSession session =request.getSession();
ArrayList array=new ArrayList();
if(change.equals("change"))
{
try{
con=new DBCon().getConnection();
String xxcxSQL="select city_id,operation_id,time_start,time_end,result_id2 from pj_evaluate where time_start between '"+time1+"' and '"+time2+"' and city_id"+cityID+" and county_id"+countyID+" and operation_id"+xxcxID+"";
stmt=con.createStatement();
System.out.println("sql:"+xxcxSQL);
ResultSet xxrs=stmt.executeQuery(xxcxSQL);
while(xxrs.next())
{
XxcxBean xb=new XxcxBean();
String mingcheng=xxrs.getString("city_id");
//在这里转换比较好哦
if("025".equals(mingcheng))mingcheng="南京";
if("0512".equals(mingcheng))mingcheng="苏州";
xb.setMingcheng(mingcheng);
String yewuleixing=xxrs.getString("operation_id");
if("1".equals(yewuleixing))yewuleixing="业务受理";
if("2".equals(yewuleixing))yewuleixing="费用缴纳";
if("3".equals(yewuleixing))yewuleixing="咨询";
if("4".equals(yewuleixing))yewuleixing="查询";
if("5".equals(yewuleixing))yewuleixing="投诉举报";
xb.setYewuleixing(yewuleixing);
String pjkssj=xxrs.getString("time_start");
xb.setPjkssj(pjkssj);
String pjjssj=xxrs.getString("time_end");
xb.setPjjssj(pjjssj);
String pjjg=xxrs.getString("result_id2");
if("1".equals(pjjg))pjjg="满意";
if("3".equals(pjjg))pjjg="不满意";
if("2".equals(pjjg))pjjg="一般";
if("0".equals(pjjg))pjjg="未评价";
xb.setPjjg(pjjg);
array.add(xb);
}
session.setAttribute("array", array);
}catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
{
con.close();
}
}catch(SQLException ee){ee.toString();}
}
}
//跳转到结果页面
RequestDispatcher rd=request.getRequestDispatcher("xxcx.jsp");
rd.forward(request, response);
}
}
3.WEB.XML
<taglib>
<taglib-uri>/WEB-INF/extremecomponents</taglib-uri>
<taglib-location>/WEB-INF/extremecomponents.tld</taglib-location>
</taglib>
</jsp-config>
4。原始未分页 显示
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import ="java.util.ArrayList" %>
<%@ page import ="com.suypower.bean.XxcxBean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<center>
<table border="4">
<tr>
<td>名称</td><td>业务类型</td><td>评价开始时间</td><td>评价结束时间</td><td>评价结果</td>
</tr>
<tr>
<!-- 使用标签 分页显示 session 中的 信息 -->
<%
ArrayList array=new ArrayList();
array=(ArrayList)session.getAttribute("array");
%>
<%
for(int i=0;i<array.size();i++)
{
%>
<%
XxcxBean xb=new XxcxBean();
xb=(XxcxBean)array.get(i);
String mingcheng=xb.getMingcheng();
String ywlx=xb.getYewuleixing();
String startTime=xb.getPjkssj();
String endTime=xb.getPjjssj();
String suc=xb.getPjjg();
%>
<td><%= mingcheng%></td>
<td><%= ywlx%></td>
<td><%= startTime%></td>
<td><%= endTime%></td>
<td><%= suc%></td>
</tr>
<%
}
%>
</table>
</center>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<七>
框架frameset模块 简单 代码 frameset head left right foot
1. frameset .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>营业厅窗口服务评价系统</title>
</head>
<frameset frameborder="0" frameSpacing="0" rows="90,480,45">
<frame name="head" src="head.jsp" noResize scrolling="no" marginwidth="0" marginheight="0">
<frameset border="false" frameSpacing="0" frameBorder="0" cols="170,560">
<frame name="left" marginWidth="0" marginHeight="0" src="left.jsp" noResize scrolling="no">
<frame name="right" marginWidth="0" src="right.jsp" scrolling="auto" noResize>
</frameset>
<frame name="bottom" src="foot.jsp" noresize scrolling="no" marginwidth="0" marginheight="0">
</frameset>
</html>
2.head .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/title01.gif" width="1009" height="100"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="8"></td>
</tr>
</table>
</body>
</html>
3.left.jsp
<%@ page language="java" pageEncoding="gb2312"%>
<html>
<body>
<head>
<meta http-equiv="refresh" content="15">
</head>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="238" height="496" valign="top" background="images/left01.gif">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="80" align="center" valign="bottom" class="a1">${qs_hs}</td>
</tr>
<tr>
<td height="80" align="center" valign="bottom"><span class="a1">${dfsf_je }</span></td>
</tr>
<tr>
<td height="75" align="center" valign="bottom"><span class="a1">${dfsf_zhh }</span></td>
</tr>
<tr>
<td height="75" align="center" valign="bottom"><span class="a1">${ywsf_zhh }</span></td>
</tr>
<tr>
<td height="70" align="center" valign="bottom"><span class="a1">${qs_rl }</span></td>
</tr>
<tr>
<td height="75" align="center" valign="bottom"><span class="a1">${ywsf_je }</span></td>
</tr>
</table></td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="9" background="images/bg01.gif"></td>
</tr>
</table>
4.right .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<html>
<head>
<title>内容页面</title>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body style='OVERFLOW:SCROLL;OVERFLOW-X:HIDDEN;'>
<form name="form1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="363"></td><!-- <img src="images/login01.gif" width="777" height="480"> -->
</tr>
</table>
</form>
</body>
</html>
5.foot .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<html>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/di01.gif" width="1024" height="40" border="0" usemap="#Map"></td>
</tr>
</table>
<map name="Map">
<area shape="rect" coords="26,11,144,31" href="ShowCharServlet?param=ywl" target="right">
<area shape="rect" coords="277,12,381,28" href="ShowCharServlet?param=dfzj" target="right">
<area shape="rect" coords="168,11,255,30" href="ShowCharServlet?param=myd" target="right">
<area shape="rect" coords="409,11,520,32" href="ShowCharServlet?param=dfywl" target="right">
<area shape="rect" coords="552,11,648,32" href="ShowCharServlet?param=ywzj" target="right">
<area shape="rect" coords="678,10,802,31" href="ShowCharServlet?param=ywslhs" target="right">
<area shape="rect" coords="834,11,974,31" href="ShowCharServlet?param=ywslrl" target="right">
</map>
</body>
</html>
FOR:其他参考代码
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
left .jsp
<%@ page language="java" pageEncoding="gbk"%>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td background="images/bg01c.gif" width="20">
</td>
<td valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td background="images/bg01d.gif" bgcolor="#f5fffa" height="34" style="width: 708px">
</td>
</tr>
<tr>
<td bgcolor="#f5fffa" valign="top" style="width: 708px">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="height: 19px">
</td>
</tr>
</table>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="20">
<font color="#000000">
<img height="20" src="images/USER0.GIF" width="20" />
</font>
</td>
<td>
<font color="#000000"> 用户名:</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="###实现此功能###"><span style="color: #333333">评价数据统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/MAILBOX.GIF"
width="16" />
<a href="yeWu.do?param=yewufenbu" target="right"><span style="color: #333333">业务分布统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/SEND_BOX.GIF" width="16" />
<a href="MainServlet?param=manyishuju" target="right"><span style="color: #333333">满意数据分析</span></a></td>
</tr>
<tr style="color: #333333">
<td style="height: 22px">
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/SEARCH.GIF" width="16" />
<a href="MainServlet?param=xiangxishuju" target="right"><span style="color: #333333">详细数据查询</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="##############"><span style="color: #333333">营销数据统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/TOOLS.GIF" width="16" />
<a href="MainServlet?param=yewuliang" target="right"><span style="color: #333333">业务量统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/TEMP_BOX.GIF" width="16" />
<a href="MainServlet?param=zijin" target="right""><span style="color: #333333">业务资金统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/SIZE.GIF"
width="16" />
<a href="MainServlet?param=dfsf" target="right""><span style="color: #333333">电费收费统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="###########3#"><span style="color: #333333">组织机构管理</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/REFUSE.GIF"
width="16" />
<a href="yeWu.do?param=dishi" target="right""><span style="color: #333333">地市信息</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/NEW_MAIL.gif"
width="16" />
<a href="yeWu.do?param=guiyuan" target="right""><span style="color: #333333">柜员信息</span></a></td>
</tr>
<tr style="color: #333333">
<td style="height: 22px">
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="#########3#"><span style="color: #333333">系统管理</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/take_mail.gif"
width="16" />
<a href="yeWu.do?param=yonghu" target="right""><span style="color: #333333">用户管理</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/RESUME.GIF"
width="16" />
<a href="infor.do" target="right"><span style="color: #333333">个人信息</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" border="0" height="22" src="images/LASTBLK.GIF" width="16" /><img
align="absMiddle" border="0" height="16" src="images/EXIT.GIF" width="16" />
<a href="login.jsp" target="right"><span
style="color: #333333"> 退 出</span></a></td>
</tr>
</table>
<p>
<br />
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<八>一个简单的 不安全的 login .jsp
package com.suypower.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.suypower.db.DBCon;
public class LoginServlet extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
String userid=request.getParameter("userId");
String psw=request.getParameter("userMm");
HttpSession session=request.getSession();
session.setAttribute("userid",userid);
try{
Connection con=new DBCon().getConnection();
Statement stmt=con.createStatement();
String sql1="select count(User_ID) as zongshu from PJ_User where User_ID='"+userid+"' and User_MM='"+psw+"'";
ResultSet rs1=stmt.executeQuery(sql1);
rs1.next();
String noing=rs1.getString("zongshu");
if(noing.equals("0"))
{
RequestDispatcher rd=request.getRequestDispatcher("error.jsp");
rd.forward(request, response);
}else
{
RequestDispatcher rd=request.getRequestDispatcher("frameset.jsp");
rd.forward(request, response);
}
}catch(SQLException e)
{
e.printStackTrace();
}
}
}
FOR; 用struts + hibernate 验证用户 login .jsp
package com.suypower.struts;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import DBConnect.DBConn;
public class LoginAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws Exception
{
// System.out.print("11111111111111111111");
ActionForward actionForward=new ActionForward();
// LoginForm lf=(LoginForm)form;
// String userID=lf.getUserId();
// String userMM=lf.getUserMm();
// System.out.println("222222222222222222");
// String sql="from PjUser as pj where pj.userId=:PJuserId and pj.userMm=:PJuserMm";
// //判断用户
// System.out.print("3333333333333");
// try{
// Session session=HibernateSessionFactory.getSession();
// //HibernateSessionFactory.getSession();
// //new Configuration().configure().buildSessionFactory().openSession();
// System.out.println("44444444444444");
// Transaction tx=session.beginTransaction();
// System.out.println("5555555555555555");
// Query query=session.createQuery(sql);
// System.out.println("666666666666666666");
// query.setString("PJuserId", userID);
// query.setString("PJuserMm", userMM);
// tx.commit();
// System.out.println("777777777777777777777");
// if(query.list().size()>0)
// {
// session.close();
// return mapping.findForward("frameset");
// }
// else
// {
// return mapping.findForward("error");
// }
// }catch(HibernateException e)
// {
// e.printStackTrace();
// }
// return actionForward;
String userid=request.getParameter("userId");
String psw=request.getParameter("userMm");
HttpSession session=request.getSession();
session.setAttribute("userid",userid);
Connection con=new DBConn().getConnection();
// String sql="select User_ID,User_MM,Popedom_ID from PJ_User where User_ID='"+userid+"' and User_MM='"+psw+"'";
// System.out.print(sql);
Statement stmt=con.createStatement();
// ResultSet rs=stmt.executeQuery(sql);
// while(rs.next())
// {
// String name=rs.getString("User_ID");
// String password=rs.getString("User_MM");
// String popodomID=rs.getString("Popedom_ID");
// session.setAttribute("popodomID", popodomID);
// }
String sql1="select count(User_ID) as zongshu from PJ_User where User_ID='"+userid+"' and User_MM='"+psw+"'";
ResultSet rs1=stmt.executeQuery(sql1);
rs1.next();
String noing=rs1.getString("zongshu");
System.out.println("ddddddddddddddd"+noing);
if(noing.equals("0"))
{
System.out.println("wwwwwwwwwwwww"+rs1.getRow());
return actionForward=mapping.findForward("error");
}
if(rs1.getRow()>0)
{
System.out.println("sssssssssssssss"+rs1.getRow());
return actionForward=mapping.findForward("frameset");
}
return actionForward;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<九>: 一个地市 信息 显示 绑订到数据库 显示 连接 (联到删除 什么对应的 功能)
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="Test.SjbdDishi" %>
<html>
<body>
<div align="center">
<table>
<tr><th>统计信息:共有${count }个地市<th></tr>
</table>
<br>
<table width="75%" border=1>
<tr><th>地市</th><th>地市区号</th><th>查看</th></tr>
<%
SjbdDishi ds=new SjbdDishi();
ds.getDSsjbd(request,out);
%>
</table>
</div>
</body>
</html>
package Test;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspWriter;
import DBConnect.DBConn;
public class SjbdDishi {
public void getDSsjbd(HttpServletRequest request,JspWriter out)
{
HttpSession session=request.getSession();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
DBConn db = new DBConn();
conn = db.getConnection();
stmt = conn.createStatement();
String sql = "select City_ID,City_NAME from dbo.PJ_City";
rs = stmt.executeQuery(sql);
while (rs.next())
{
int count=rs.getRow();
session.setAttribute("count", count);
String cityID=rs.getString("City_ID");
String cityNAME=rs.getString("City_NAME");
out.print("<tr><td>"+cityID+"</td><td>"+cityNAME+"</td>");
out.print("<td><a href=dsView.do?param="+rs.getString("City_ID")+">查看</a></td>");
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
}
}
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
jdbc 连接
package com.suypower.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBCon {
final private String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
final private String driverURL="jdbc:sqlserver://172.23.23.3:1433;databaseName=pjtest";
final private String username="pj";
final private String password="pj3023";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
public Connection getConnection()
{
try
{
Class.forName(driverName);
}catch(ClassNotFoundException e)
{
System.out.println("%%%连接驱动失败%%%");
e.printStackTrace();
}
try
{
con=DriverManager.getConnection(driverURL,username,password);
}catch(SQLException e)
{
e.printStackTrace();
System.out.println("%%%连接数据库失败%%%");
}
finally
{
}
return con;
}
}
%%%%%%%%%%%%%%%%%%%%%%-2007-12-18-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
extremeComponents 的删除 和编辑弹出页面 实现
1。分页信息输出
<div align="center" id="cz" >
<ec:table
action="${pageContext.request.contextPath}/BmServlet"
items="arrayBM"
var="a"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
width="99%"
tableId="resultTable1"
rowsDisplayed="10"
form="frm"
filterable="false"
sortable="false"
autoIncludeParameters="false">
<ec:row>
<ec:column property="city_id" title="【所属地市】" width="16%"></ec:column>
<ec:column property="county_id" title="【分县公司】" width="16%"></ec:column>
<ec:column property="bm_id" title="【所属部门】" width="16%"></ec:column>
<ec:column property="person_id" title="【员工工号】" width="16%"></ec:column>
<ec:column property="person_name" title="【员工姓名】" width="16%"></ec:column>
<ec:column property="【编辑】" title="" width="10%">
<input type="button" value="编辑" name="space">
</ec:column>
<ec:column property="【删除】" title="" width="10%">
<input type="button" value="删除" onclick="del('${a.person_id }')">
</ec:column>
</ec:row>
</ec:table>
<input type="hidden" name="shanchu">
</div>
2。
。。。。
。。。
function del(person_id)
{
document.frm.change.value="shanchu";
document.frm.shanchu.value=person_id;
frm.submit();
}
</script>
3。servlet 获取参数 然后 连接数据库 执行删除
。。。
。。。。
if(param.equals("shanchu"))
{
String person_id=request.getParameter("shanchu");
//写SQL语句 删除
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
System.out.println(person_id);
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
编辑
思路:用分页组件 extremecomponents 实现 编辑
然后 传参数
用JS实现 弹出页面
页面上是用JSP
然后用的是 JS限制格式
JSP action=到 SERVLET
SERVLET 获取 参数
连接数据库 update 数据 即可
很清晰的思路哦
代码:
<div align="center" id="cz" >
<ec:table
action="${pageContext.request.contextPath}/BmServlet"
items="arrayBM"
var="a"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
width="99%"
tableId="resultTable1"
rowsDisplayed="10"
form="frm"
filterable="false"
sortable="false"
autoIncludeParameters="false">
<ec:row>
<ec:column property="city_id" title="【所属地市】" width="16%"></ec:column>
<ec:column property="county_id" title="【分县公司】" width="16%"></ec:column>
<ec:column property="bm_id" title="【所属部门】" width="16%"></ec:column>
<ec:column property="person_id" title="【员工工号】" width="16%"></ec:column>
<ec:column property="person_name" title="【员工姓名】" width="16%"></ec:column>
<ec:column property="【编辑】" title="" width="10%">
<input type="button" value="编辑" onclick="edit('${a.person_id }','${a.city_id }','${a.county_id }','${a.bm_id }','${a.person_name }')" >
</ec:column>
<ec:column property="【删除】" title="" width="10%">
<input type="button" value="删除" onclick="del('${a.person_id }')">
</ec:column>
</ec:row>
</ec:table>
<input type="hidden" name="shanchu">
</div>
....
...
function edit(person_id,city_id,county_id,bm_id,person_name)
{
url="edit.jsp?personid="+person_id+"&cityid="+city_id+"&countyid="+county_id+"&bmid="+bm_id+"&personName="+person_name;
//alert(url);
window.open(url,'newwindow','height=250,width=400,top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}
</script>
JSP
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<%
String personid=new String(request.getParameter("personid").getBytes("iso8859-1"),"gbk");
String cityid=new String(request.getParameter("cityid").getBytes("iso8859-1"),"gbk");
String countyid=new String(request.getParameter("countyid").getBytes("iso8859-1"),"gbk");
String bmid=new String(request.getParameter("bmid").getBytes("iso8859-1"),"gbk");
String personName=new String(request.getParameter("personName").getBytes("iso8859-1"),"gbk");
%>
<form action="EditServlet" method="post">
<table>
<tr><td>用户ID:</td><td><%= personid %></td></tr>
<tr><td>用户名:</td><td><%= personName %></td></tr>
<tr><td>城市:</td><td><%= cityid %></td></tr>
<tr><td>区县:</td><td><input type="text" value="<%= countyid %>" name="aaa"></td></tr>
<tr><td>部门:</td><td><input type="text" value="<%= bmid %>" name="bbb"></td></tr>
<tr>
<td>是否为服务人员:</td>
<td>
<select name="fuwu">
<option>是</option>
<option>否</option>
</select>
</td></tr>
<tr><td><input type="submit" value="确定"></td></tr>
</table>
</form>
</body>
</html>
Servlet
。。。。。。。。。
获取表单信息 写SQL 更新 即可 很简单的 这里就不给代码了
//////////////////////////////////////////////////2007-12-19//////////////////////////////////////////////////////////。。。。。。。。。。。。。。。AJAX 联动。。。。。。。。。。。。。。。
ajax
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
This is my ajax JSP page. <br>
<head>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActionXObject)
{
xmlHttp=new ActionXObject("Microsoft.XMLHTTP");
}
elst if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
function startRequest()
{
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlRequest.open("get","innerHTML",true);
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
document.getElementById("results").innerHTML=xmlHttp.responseText;
}
}
}
}
</script>
</head>
<body>
<form action="#">
<input type="button" value="ajax" onclick="startRequest();"/>
<div id="results"></div>
</form>
</body>
</html>
innerHTML.xml
...
.....
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ajax 实现级联下拉 更新 数据库
<head>
<script language ="javascript">
var http_request = false;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{ //IE浏览器
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function Change_Select(){
var cityID=document.frm.city.value;
createXMLHttpRequest();
http_request.onreadystatechange=callback;
http_request.open("get","TestServlet?cityid="+cityID,true);
http_request.send(null);
}
function callback(){
if(http_request.readyState == 4)
{
if(http_request.status == 200)
{
var str=http_request.responseText;
if(str!=null)
{
var field=str.split("|");
}
document.getElementById("county").length=0;//调用之前先置为空
for(var i=0;i<field.length-1;i++)
{
var option=field[i].split(",");
document.frm.county.add(new Option(option[0],option[0]));
}
}else {
alert("http_request.status == 200 失败");
}
}
}
</script>
</head>
<body>
<form name="frm" action="YwlServlet" method="post">
.......................
<select name="city" onChange="Change_Select()">
<option>==请先选择地市==</option>
<option value="025">南京</option>
<option value="0511">镇江</option>
<option value="0519">常州</option>
....................
.................
...
<td>
<select name="county">
<option>==所有区县==</option>
</select>
</td>
..............
servlet
...
..
package com.suypower.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.suypower.db.DBCon;
public class TestServlet extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
response.setContentType("text/html");
response.setCharacterEncoding("gb2312");
doPost(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
//String cityID=request.getParameter("cityid");
Connection con=null;
Statement stmt=null;
PrintWriter out=response.getWriter();
request.setCharacterEncoding("gb2312");
response.setContentType("text/html");
response.setCharacterEncoding("gb2312");
try{
con=new com.suypower.db.DBCon().getConnection();
stmt=con.createStatement();
String sql="select county_name from pj_county";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
String county_name=rs.getString("county_name");
out.print(county_name+"|");
}
}catch(SQLException e){e.printStackTrace();}
}
}
¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
程雨__级联菜单__树型结构
不要着急 我们 来 先看看API
Overview
Functions
add
openAll
closeAll
openTo
Configuration
Functions
add()
Adds a node to the tree.
Can only be called before the tree is drawn.
id, pid and name are required.
Parameters
Name Type Description
id Number Unique identity number.
pid Number Number refering to the parent node. The value for the root node has to be -1.
name String Text label for the node.
url String
偶的JAVA 随记
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<一>表单 提交 条件 JSP-SERVLET-JSP 获取数据库的信息 返回给控制台
1. JSP
用户的半动态表单
<%@ page language="java" pageEncoding="gbk"%>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.jsp.JspWriter"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script lanaguage="javascript">
function btnQuyu_Onclick(q)
{
if(q.selectedIndex==1){
document.frm.city.style.display = "none";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==2){
document.frm.city.style.display = "";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==3){
document.frm.city.style.display = "";
document.frm.county.style.display = "";
}
}
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array("城北供电公司","=025","=1");//county ,分组,countyID
subcat[1] = new Array("城南供电公司","=025","=2");
subcat[2] = new Array("栖霞供电公司","=025","=3");
subcat[3] = new Array("雨花供电公司","=025","=4");
subcat[4] = new Array("溧水供电公司","=025","=6");
subcat[5] = new Array("高淳供电公司","=025","=7");
subcat[6] = new Array("六合供电公司","=025","=8");
subcat[7] = new Array("浦口供电公司","=025","=9");
subcat[8] = new Array("江宁供电公司","=025","=10");
subcat[9] = new Array("计量中心","=025","=12");
subcat[10] = new Array("镇江分县1","0511","004");
subcat[11] = new Array("镇江分县2","0511","005");
subcat[12] = new Array("镇江分县3","0511","006");
onecount=13;
function changelocation(locationid)
{
document.frm.county.length = 0;
var locationid=locationid;
var i;
document.frm.county.options[0] = new Option('====所有区县====','!=0');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.frm.county.options[document.frm.county.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
</head>
<body>
<form name="frm" action="XxcxServlet" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="6"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="4" cellspacing="1">
<tr align="center" bgcolor="#EBEADB">
<td colspan="5" >详细数据查询</td>
</tr>
<tr>
<td height="14" align="left" >选择时间段:</td>
</tr>
<tr>
<td bgcolor="#f4f4f4" colspan="3">
<select name="year1">
<option>2006</option>
</select>日
</td>
</tr>
<tr bgcolor="#FFFFFF">
</tr>
<tr>
<td>
<select name="quyu" onchange="btnQuyu_Onclick(this);">
<option>==请先选择区域==</option>
<option value="aqs">按全省</option>
<option value="ads">按地市</option>
<option value="aqx">按区县</option>
</select>
</td>
</tr>
<tr bgcolor="#f4f4f4" >
<td>
<!-- 新小知识点 -->
<select name="city" onChange="changelocation(document.frm.city.options[document.frm.city.selectedIndex].value)">
<option value="!=0">==请先选择地市==</option>
<option value="=025">南京</option>
<option value="=0511">镇江</option>
<option value="=0519">常州</option>
<option value="=0516">徐州</option>
<option value="=0512">苏州</option>
<option value="=0510">无锡</option>
<option value="=0513">南通</option>
<option value="=0527">宿迁</option>
<option value="=0514">扬州</option>
<option value="=0523">泰州</option>
<option value="=0517">淮安</option>
<option value="=0515">盐城</option>
<option value="=0518">连云港</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="county">
<option>==所有区县==</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="xxcx">
<option value="!=0">==请选择业务类型==</option>
<option value="!=0">全部</option>
<option value="=1">业务受理</option>
<option value="=2">费用缴纳</option>
<option value="=3">咨询</option>
<option value="=4">查询</option>
<option value="=5">投诉举报</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" value="确定"></td>
</tr>
</table>
</form>
<script LANGUAGE="javascript">
<!--
changelocation(document.frm.city.options[document.frm.city.selectedIndex].value);
//-->
</script>
</body>
</html>
2.
获取数据库中的信息 返回 JSP
Servlet
package com.suypower.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.suypower.bean.XxcxBean;
import com.suypower.db.DBCon;
public class XxcxServlet extends HttpServlet{
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
//获取表单信息
//1。 获取表单 时间 信息
String year1=request.getParameter("year1");
String month1=request.getParameter("month1");
String day1=request.getParameter("day1");
String year2=request.getParameter("year2");
String month2=request.getParameter("month2");
String day2=request.getParameter("day2");
String time1=year1+"-"+month1+"-"+day1;
String time2=year2+"-"+month2+"-"+day2;
System.out.println("时间范围:"+time1+" and "+time2);
//2。城市ID 转换
String cityID=new String(request.getParameter("city").getBytes("iso8859-1"),"GBK");
System.out.println("城市ID:"+cityID);
//3。指标
String xxcxID=new String(request.getParameter("xxcx").getBytes("iso8859-1"),"GBK");
System.out.println("业务类型:"+xxcxID);
//4.county
String countyID=new String(request.getParameter("county").getBytes("iso8859-1"),"GBK");
//String county=request.getParameter("county");
System.out.println("地市ID:"+countyID);
//这里ywl.jsp页面上已经定义了,不用在这里转换了
//5.区域获取
String quyu=new String(request.getParameter("quyu").getBytes("iso8859-1"),"GBK");
System.out.println("选择区域是按:"+quyu);
Connection con=null;
Statement stmt=null;
HttpSession session =request.getSession();
ArrayList array=new ArrayList();
try{
con=new DBCon().getConnection();
String xxcxSQL="select city_id,operation_id,time_start,time_end,result_id2 from pj_evaluate where time_start between '"+time1+"' and '"+time2+"' and city_id"+cityID+" and county_id"+countyID+" and operation_id"+xxcxID+"";
stmt=con.createStatement();
System.out.println("sql:"+xxcxSQL);
ResultSet xxrs=stmt.executeQuery(xxcxSQL);
while(xxrs.next())
{
XxcxBean xb=new XxcxBean();
String mingcheng=xxrs.getString("city_id");
//在这里转换比较好哦
xb.setMingcheng(mingcheng);
String yewuleixing=xxrs.getString("operation_id");
xb.setYewuleixing(yewuleixing);
String pjkssj=xxrs.getString("time_start");
xb.setPjkssj(pjkssj);
String pjjssj=xxrs.getString("time_end");
xb.setPjjssj(pjjssj);
String pjjg=xxrs.getString("result_id2");
xb.setPjjg(pjjg);
array.add(xb);
}
session.setAttribute("array", array);
}catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
{
con.close();
}
}catch(SQLException ee){ee.toString();}
}
//跳转到结果页面
RequestDispatcher rd=request.getRequestDispatcher("xxcx_jg.jsp");
rd.forward(request, response);
}
}
3。最终结果
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import ="java.util.ArrayList" %>
<%@ page import ="com.suypower.bean.XxcxBean" %>
<%@ taglib uri="/WEB-INF/extremecomponents" prefix="ec"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<center>
<table border="4">
<tr>
<td>名称</td><td>业务类型</td><td>评价开始时间</td><td>评价结束时间</td><td>评价结果</td>
</tr>
<tr>
<!-- 使用标签 分页显示 session 中的 信息 -->
<%
ArrayList array=new ArrayList();
array=(ArrayList)session.getAttribute("array");
%>
<%
for(int i=0;i<array.size();i++)
{
%>
<%
XxcxBean xb=new XxcxBean();
xb=(XxcxBean)array.get(i);
String mingcheng=xb.getMingcheng();
String ywlx=xb.getYewuleixing();
String startTime=xb.getPjkssj();
String endTime=xb.getPjjssj();
String suc=xb.getPjjg();
%>
<td><%= mingcheng%></td>
<td><%= ywlx%></td>
<td><%= startTime%></td>
<td><%= endTime%></td>
<td><%= suc%></td>
</tr>
<%
}
%>
</table>
</center>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<二>一个 下拉 动态 读取 数据库
FOR:
1.
package Test;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import DBConnect.DBConn;
public class Bumen {
public void getBumen(HttpServletRequest request,JspWriter out) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
DBConn db = new DBConn();
conn = db.getConnection();
stmt = conn.createStatement();
String sql = "select distinct bm_name from PJ_BM";
rs = stmt.executeQuery(sql);
String html ="";
while (rs.next())
{
String bm_name=rs.getString("bm_name");
out.print("<option>"+bm_name+"</option>");
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
e.getMessage();
}
}
}
}
2.JSP
<td>
<select name="city">
<option>-请选择城市-</option>
<%
Bumen bm=new Bumen();
bm.getBumen(request,out);
%>
</select>
</td>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<三>.
一个简单的柱状报表
后台 获取 数据库的 SQL 信息 放到 SESSION
前台 显示
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="org.jfree.chart.ChartFactory,
java.awt.Color,
java.awt.Font,
org.jfree.chart.JFreeChart,
org.jfree.chart.axis.ValueAxis,
org.jfree.chart.labels.StandardCategoryItemLabelGenerator,
org.jfree.chart.plot.CategoryPlot,
org.jfree.chart.plot.PlotOrientation,
org.jfree.chart.renderer.category.*,
org.jfree.chart.servlet.ServletUtilities,
org.jfree.data.category.CategoryDataset,
org.jfree.data.category.DefaultCategoryDataset" %>
<html>
<body>
<%
String category="江苏营业厅";
double NJhushu=Double.parseDouble(session.getAttribute("NJhushu").toString());
double SZhushu=Double.parseDouble(session.getAttribute("SZhushu").toString());
double WXhushu=Double.parseDouble(session.getAttribute("WXhushu").toString());
double CZhushu=Double.parseDouble(session.getAttribute("CZhushu").toString());
double YZhushu=Double.parseDouble(session.getAttribute("YZhushu").toString());
double NThushu=Double.parseDouble(session.getAttribute("NThushu").toString());
double SQhushu=Double.parseDouble(session.getAttribute("SQhushu").toString());
double XZhushu=Double.parseDouble(session.getAttribute("XZhushu").toString());
double HAhushu=Double.parseDouble(session.getAttribute("HAhushu").toString());
double ZJhushu=Double.parseDouble(session.getAttribute("ZJhushu").toString());
double TZhushu=Double.parseDouble(session.getAttribute("TZhushu").toString());
double YChushu=Double.parseDouble(session.getAttribute("YChushu").toString());
double LYGhushu=Double.parseDouble(session.getAttribute("LYGhushu").toString());
CategoryDataset dataset=this.getDataSet(NJhushu,SZhushu,WXhushu,CZhushu,YZhushu,NThushu,SQhushu,XZhushu,HAhushu,ZJhushu,TZhushu,YChushu,LYGhushu);
String title=category+"受理户数总工号";
JFreeChart chart = ChartFactory.createBarChart3D
(
title,
"城市",
"申请户数",
dataset,
PlotOrientation.VERTICAL,
true,
false,
false
);
String filename = ServletUtilities.saveChartAsPNG(chart,750,350, null, session);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
<P ALIGN="CENTER">
<img src="<%= graphURL %>" width=750 height=350 border=0 usemap="#<%= filename %>">
</P>
<%!
public static CategoryDataset getDataSet(double NJhushu,double SZhushu,double WXhushu,double CZhushu,double YZhushu,double NThushu,double SQhushu,double XZhushu,double HAhushu,double ZJhushu,double TZhushu,double YChushu,double LYGhushu)
{
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(NJhushu,"南京","南京");
dataset.addValue(SZhushu, "苏州", "苏州");
dataset.addValue(WXhushu, "无锡", "无锡");
dataset.addValue(CZhushu, "常州", "常州");
dataset.addValue(YZhushu, "扬州", "扬州");
dataset.addValue(NThushu, "南通", "南通");
dataset.addValue(SQhushu, "宿迁", "宿迁");
dataset.addValue(XZhushu, "徐州", "徐州");
dataset.addValue(HAhushu, "淮安", "淮安");
dataset.addValue(ZJhushu, "镇江", "镇江");
dataset.addValue(TZhushu, "泰州", "泰州");
dataset.addValue(YChushu, "盐城", "盐城");
dataset.addValue(LYGhushu, "连云港", "连云港");
return dataset;
}
%>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<四>.动态显示数据 导出报表 SQL 读取 到 BEAN 中 这里用的SQL是子查询 全部写入
FOR:
SQL=select a.county_id,a.county_name,
(select count(b.yw_zhh) from pj_yxyw b where b.county_id = a.county_id) as county_zhh,
(select abs(sum(cast(b.yw_rl as int))) from pj_yxyw b where b.county_id = a.county_id)as county_rl,
(select count(c.dfsf_zhh) from pj_yxdfsf c where c.county_id = a.county_id) as county_dfsf_zhh,
(select sum(cast(c.dfsf_je as decimal(35,2))) from pj_yxdfsf c where c.county_id = a.county_id)as county_dfsf_je,
(select count(d.ywsf_zhh) from pj_yxywsf d where d.county_id=a.county_id)as county_ywsf_zhh,
(select sum(cast(e.ywsf_je as decimal(35,2))) from pj_yxywsf e where e.county_id = a.county_id)as county_ywsf_je,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='1') as county_my,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='3') as county_bmy,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='2') as county_yb,
(select count(f.result_id) from pj_evaluate f where f.county_id=a.county_id and result_id='0') as county_wpj
from pj_county a where a.city_id='"+cityID+"'
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="org.jfree.chart.ChartFactory,
java.awt.Color,
java.awt.Font,
org.jfree.chart.JFreeChart,
org.jfree.chart.axis.ValueAxis,
org.jfree.chart.labels.StandardCategoryItemLabelGenerator,
org.jfree.chart.plot.CategoryPlot,
org.jfree.chart.plot.PlotOrientation,
org.jfree.chart.renderer.category.*,
org.jfree.chart.servlet.ServletUtilities,
org.jfree.data.category.CategoryDataset,
org.jfree.data.category.DefaultCategoryDataset" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.suypower.bean.YwlBean" %>
<html>
<body>
<%
CategoryDataset dataset;
String category="营业厅";
ArrayList array=new ArrayList();
array=(ArrayList)session.getAttribute("array");
dataset=this.getDataSet(array);
String title=category+"受理总工号统计";
JFreeChart chart = ChartFactory.createBarChart3D(title,
"区县",
"受理总工号统计",
dataset,
PlotOrientation.VERTICAL,
true,
false,
false);
String filename = ServletUtilities.saveChartAsPNG(chart,750, 480, null, session);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
<P ALIGN="CENTER">
<img src="<%= graphURL %>" border=0 usemap="#<%= filename %>">
</P>
<%!public static CategoryDataset getDataSet(ArrayList array)
{
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for(int i=0;i<array.size();i++)
{
YwlBean yb=(YwlBean)array.get(i);
System.out.println("城市名字"+yb.getCounty_name()+","+"户数"+yb.getCounty_zhh()+"");
dataset.addValue(Double.parseDouble(yb.getCounty_zhh().toString()),yb.getCounty_name().toString(),yb.getCounty_name().toString());
}
return dataset;
}%>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<六>
1.分页组件 extremecomponents 使用 规范 JSP 用到图片 table images 和 JAR ,TLD
<%@ page language="java" pageEncoding="gbk"%>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.jsp.JspWriter"%>
<%@ taglib uri="/WEB-INF/extremecomponents" prefix="ec"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script lanaguage="javascript">
function btnQuyu_Onclick(q)
{
if(q.selectedIndex==1){
document.frm.city.style.display = "none";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==2){
document.frm.city.style.display = "";
document.frm.county.style.display = "none";
}
if(q.selectedIndex==3){
document.frm.city.style.display = "";
document.frm.county.style.display = "";
}
}
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array("城北供电公司","=025","=1");//county ,分组,countyID
subcat[1] = new Array("城南供电公司","=025","=2");
subcat[2] = new Array("栖霞供电公司","=025","=3");
subcat[3] = new Array("雨花供电公司","=025","=4");
subcat[4] = new Array("溧水供电公司","=025","=6");
subcat[5] = new Array("高淳供电公司","=025","=7");
subcat[6] = new Array("六合供电公司","=025","=8");
subcat[7] = new Array("浦口供电公司","=025","=9");
subcat[8] = new Array("江宁供电公司","=025","=10");
subcat[9] = new Array("计量中心","=025","=12");
subcat[10] = new Array("镇江分县1","=0511","004");
subcat[11] = new Array("镇江分县2","=0511","005");
subcat[12] = new Array("镇江分县3","=0511","006");
onecount=13;
function changelocation(locationid)
{
document.frm.county.length = 0;
var locationid=locationid;
var i;
document.frm.county.options[0] = new Option('====所有区县====','!=0');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.frm.county.options[document.frm.county.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
function showtable()
{
document.frm.change.value="change";
frm.submit();
}
</script>
</head>
<body>
<form name="frm" action="XxcxServlet" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="12"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="6"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="4" cellspacing="1">
<tr align="center" bgcolor="#EBEADB">
<td colspan="5" >详细数据查询</td>
</tr>
<tr>
<td height="14" align="left" >选择时间段:</td>
</tr>
<tr>
</select>日
</td>
</tr>
<tr bgcolor="#FFFFFF">
</tr>
<tr>
<td>
<select name="quyu" onchange="btnQuyu_Onclick(this);">
<option>==请先选择区域==</option>
<option value="aqs">按全省</option>
<option value="ads">按地市</option>
<option value="aqx">按区县</option>
</select>
</td>
</tr>
<tr bgcolor="#f4f4f4" >
<td>
<!-- 新小知识点 -->
<select name="city" onChange="changelocation(document.frm.city.options[document.frm.city.selectedIndex].value)">
<option value="!=0">==请先选择地市==</option>
<option value="=025">南京</option>
<option value="=0511">镇江</option>
<option value="=0519">常州</option>
<option value="=0516">徐州</option>
<option value="=0512">苏州</option>
<option value="=0510">无锡</option>
<option value="=0513">南通</option>
<option value="=0527">宿迁</option>
<option value="=0514">扬州</option>
<option value="=0523">泰州</option>
<option value="=0517">淮安</option>
<option value="=0515">盐城</option>
<option value="=0518">连云港</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="county">
<option>==所有区县==</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="xxcx">
<option value="!=0">==请选择业务类型==</option>
<option value="!=0">全部</option>
<option value="=1">业务受理</option>
<option value="=2">费用缴纳</option>
<option value="=3">咨询</option>
<option value="=4">查询</option>
<option value="=5">投诉举报</option>
</select>
</td>
</tr>
<tr>
<td><input type="button" value="确定" onclick="showtable()">
<input type="hidden" name="change">
</td>
</tr>
</table>
<div align="center" id="cz" >
<ec:table
action="${pageContext.request.contextPath}/XxcxServlet"
items="array"
var="a"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
width="99%"
tableId="resultTable1"
rowsDisplayed="10"
form="frm"
filterable="false"
sortable="false"
autoIncludeParameters="false">
<ec:row>
<ec:column property="mingcheng" title="【名称】" width="10%"></ec:column>
<ec:column property="yewuleixing" title="【业务类型】" width="15%"></ec:column>
<ec:column property="pjkssj" title="【评价开始时间】" width="25%"></ec:column>
<ec:column property="pjjssj" title="【评价结束时间】" width="25%"></ec:column>
<ec:column property="pjjg" title="【评价结果】" width="20%"></ec:column>
</ec:row>
</ec:table>
</div>
</form>
<script LANGUAGE="javascript">
<!--
changelocation(document.frm.city.options[document.frm.city.selectedIndex].value);
//-->
</script>
</body>
</html>
2.
SERVLET
package com.suypower.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.suypower.bean.XxcxBean;
import com.suypower.db.DBCon;
public class XxcxServlet extends HttpServlet{
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
//获取表单信息
//1。 获取表单 时间 信息
String year1=request.getParameter("year1");
String month1=request.getParameter("month1");
String day1=request.getParameter("day1");
String year2=request.getParameter("year2");
String month2=request.getParameter("month2");
String day2=request.getParameter("day2");
String time1=year1+"-"+month1+"-"+day1;
String time2=year2+"-"+month2+"-"+day2;
System.out.println("时间范围:"+time1+" and "+time2);
//2。城市ID 转换
String cityID=new String(request.getParameter("city").getBytes("iso8859-1"),"GBK");
System.out.println("城市ID:"+cityID);
//3。指标
String xxcxID=new String(request.getParameter("xxcx").getBytes("iso8859-1"),"GBK");
System.out.println("业务类型:"+xxcxID);
//4.county
String countyID=new String(request.getParameter("county").getBytes("iso8859-1"),"GBK");
//String county=request.getParameter("county");
System.out.println("地市ID:"+countyID);
//这里ywl.jsp页面上已经定义了,不用在这里转换了
//5.区域获取
//--------------------------------------------------------------------------------//
String change=request.getParameter("change");
//--------------------------------------------------------------------------------//
String quyu=new String(request.getParameter("quyu").getBytes("iso8859-1"),"GBK");
System.out.println("选择区域是按:"+quyu);
Connection con=null;
Statement stmt=null;
HttpSession session =request.getSession();
ArrayList array=new ArrayList();
if(change.equals("change"))
{
try{
con=new DBCon().getConnection();
String xxcxSQL="select city_id,operation_id,time_start,time_end,result_id2 from pj_evaluate where time_start between '"+time1+"' and '"+time2+"' and city_id"+cityID+" and county_id"+countyID+" and operation_id"+xxcxID+"";
stmt=con.createStatement();
System.out.println("sql:"+xxcxSQL);
ResultSet xxrs=stmt.executeQuery(xxcxSQL);
while(xxrs.next())
{
XxcxBean xb=new XxcxBean();
String mingcheng=xxrs.getString("city_id");
//在这里转换比较好哦
if("025".equals(mingcheng))mingcheng="南京";
if("0512".equals(mingcheng))mingcheng="苏州";
xb.setMingcheng(mingcheng);
String yewuleixing=xxrs.getString("operation_id");
if("1".equals(yewuleixing))yewuleixing="业务受理";
if("2".equals(yewuleixing))yewuleixing="费用缴纳";
if("3".equals(yewuleixing))yewuleixing="咨询";
if("4".equals(yewuleixing))yewuleixing="查询";
if("5".equals(yewuleixing))yewuleixing="投诉举报";
xb.setYewuleixing(yewuleixing);
String pjkssj=xxrs.getString("time_start");
xb.setPjkssj(pjkssj);
String pjjssj=xxrs.getString("time_end");
xb.setPjjssj(pjjssj);
String pjjg=xxrs.getString("result_id2");
if("1".equals(pjjg))pjjg="满意";
if("3".equals(pjjg))pjjg="不满意";
if("2".equals(pjjg))pjjg="一般";
if("0".equals(pjjg))pjjg="未评价";
xb.setPjjg(pjjg);
array.add(xb);
}
session.setAttribute("array", array);
}catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
{
con.close();
}
}catch(SQLException ee){ee.toString();}
}
}
//跳转到结果页面
RequestDispatcher rd=request.getRequestDispatcher("xxcx.jsp");
rd.forward(request, response);
}
}
3.WEB.XML
<taglib>
<taglib-uri>/WEB-INF/extremecomponents</taglib-uri>
<taglib-location>/WEB-INF/extremecomponents.tld</taglib-location>
</taglib>
</jsp-config>
4。原始未分页 显示
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import ="java.util.ArrayList" %>
<%@ page import ="com.suypower.bean.XxcxBean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<center>
<table border="4">
<tr>
<td>名称</td><td>业务类型</td><td>评价开始时间</td><td>评价结束时间</td><td>评价结果</td>
</tr>
<tr>
<!-- 使用标签 分页显示 session 中的 信息 -->
<%
ArrayList array=new ArrayList();
array=(ArrayList)session.getAttribute("array");
%>
<%
for(int i=0;i<array.size();i++)
{
%>
<%
XxcxBean xb=new XxcxBean();
xb=(XxcxBean)array.get(i);
String mingcheng=xb.getMingcheng();
String ywlx=xb.getYewuleixing();
String startTime=xb.getPjkssj();
String endTime=xb.getPjjssj();
String suc=xb.getPjjg();
%>
<td><%= mingcheng%></td>
<td><%= ywlx%></td>
<td><%= startTime%></td>
<td><%= endTime%></td>
<td><%= suc%></td>
</tr>
<%
}
%>
</table>
</center>
</body>
</html>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<七>
框架frameset模块 简单 代码 frameset head left right foot
1. frameset .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>营业厅窗口服务评价系统</title>
</head>
<frameset frameborder="0" frameSpacing="0" rows="90,480,45">
<frame name="head" src="head.jsp" noResize scrolling="no" marginwidth="0" marginheight="0">
<frameset border="false" frameSpacing="0" frameBorder="0" cols="170,560">
<frame name="left" marginWidth="0" marginHeight="0" src="left.jsp" noResize scrolling="no">
<frame name="right" marginWidth="0" src="right.jsp" scrolling="auto" noResize>
</frameset>
<frame name="bottom" src="foot.jsp" noresize scrolling="no" marginwidth="0" marginheight="0">
</frameset>
</html>
2.head .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/title01.gif" width="1009" height="100"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="8"></td>
</tr>
</table>
</body>
</html>
3.left.jsp
<%@ page language="java" pageEncoding="gb2312"%>
<html>
<body>
<head>
<meta http-equiv="refresh" content="15">
</head>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="238" height="496" valign="top" background="images/left01.gif">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="80" align="center" valign="bottom" class="a1">${qs_hs}</td>
</tr>
<tr>
<td height="80" align="center" valign="bottom"><span class="a1">${dfsf_je }</span></td>
</tr>
<tr>
<td height="75" align="center" valign="bottom"><span class="a1">${dfsf_zhh }</span></td>
</tr>
<tr>
<td height="75" align="center" valign="bottom"><span class="a1">${ywsf_zhh }</span></td>
</tr>
<tr>
<td height="70" align="center" valign="bottom"><span class="a1">${qs_rl }</span></td>
</tr>
<tr>
<td height="75" align="center" valign="bottom"><span class="a1">${ywsf_je }</span></td>
</tr>
</table></td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="9" background="images/bg01.gif"></td>
</tr>
</table>
4.right .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<html>
<head>
<title>内容页面</title>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body style='OVERFLOW:SCROLL;OVERFLOW-X:HIDDEN;'>
<form name="form1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="363"></td><!-- <img src="images/login01.gif" width="777" height="480"> -->
</tr>
</table>
</form>
</body>
</html>
5.foot .jsp
<%@ page language="java" pageEncoding="gb2312"%>
<html>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/di01.gif" width="1024" height="40" border="0" usemap="#Map"></td>
</tr>
</table>
<map name="Map">
<area shape="rect" coords="26,11,144,31" href="ShowCharServlet?param=ywl" target="right">
<area shape="rect" coords="277,12,381,28" href="ShowCharServlet?param=dfzj" target="right">
<area shape="rect" coords="168,11,255,30" href="ShowCharServlet?param=myd" target="right">
<area shape="rect" coords="409,11,520,32" href="ShowCharServlet?param=dfywl" target="right">
<area shape="rect" coords="552,11,648,32" href="ShowCharServlet?param=ywzj" target="right">
<area shape="rect" coords="678,10,802,31" href="ShowCharServlet?param=ywslhs" target="right">
<area shape="rect" coords="834,11,974,31" href="ShowCharServlet?param=ywslrl" target="right">
</map>
</body>
</html>
FOR:其他参考代码
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
left .jsp
<%@ page language="java" pageEncoding="gbk"%>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td background="images/bg01c.gif" width="20">
</td>
<td valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td background="images/bg01d.gif" bgcolor="#f5fffa" height="34" style="width: 708px">
</td>
</tr>
<tr>
<td bgcolor="#f5fffa" valign="top" style="width: 708px">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="height: 19px">
</td>
</tr>
</table>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="20">
<font color="#000000">
<img height="20" src="images/USER0.GIF" width="20" />
</font>
</td>
<td>
<font color="#000000"> 用户名:</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="###实现此功能###"><span style="color: #333333">评价数据统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/MAILBOX.GIF"
width="16" />
<a href="yeWu.do?param=yewufenbu" target="right"><span style="color: #333333">业务分布统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/SEND_BOX.GIF" width="16" />
<a href="MainServlet?param=manyishuju" target="right"><span style="color: #333333">满意数据分析</span></a></td>
</tr>
<tr style="color: #333333">
<td style="height: 22px">
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/SEARCH.GIF" width="16" />
<a href="MainServlet?param=xiangxishuju" target="right"><span style="color: #333333">详细数据查询</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="##############"><span style="color: #333333">营销数据统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/TOOLS.GIF" width="16" />
<a href="MainServlet?param=yewuliang" target="right"><span style="color: #333333">业务量统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" src="images/LINE.GIF" /><img align="absMiddle" src="images/MIDBLK.GIF" /><img
align="absMiddle" border="0" height="16" src="images/TEMP_BOX.GIF" width="16" />
<a href="MainServlet?param=zijin" target="right""><span style="color: #333333">业务资金统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/SIZE.GIF"
width="16" />
<a href="MainServlet?param=dfsf" target="right""><span style="color: #333333">电费收费统计</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="###########3#"><span style="color: #333333">组织机构管理</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/REFUSE.GIF"
width="16" />
<a href="yeWu.do?param=dishi" target="right""><span style="color: #333333">地市信息</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/NEW_MAIL.gif"
width="16" />
<a href="yeWu.do?param=guiyuan" target="right""><span style="color: #333333">柜员信息</span></a></td>
</tr>
<tr style="color: #333333">
<td style="height: 22px">
<img align="absMiddle" border="0" height="22" src="images/midminus1.gif" width="16" /><img
align="absMiddle" border="0" height="16" src="images/FOLDER01.GIF" width="16" />
<a href="#########3#"><span style="color: #333333">系统管理</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/take_mail.gif"
width="16" />
<a href="yeWu.do?param=yonghu" target="right""><span style="color: #333333">用户管理</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" height="22" src="images/LINE.GIF" width="16" /><img align="absMiddle"
src="images/MIDBLK.GIF" /><img align="absMiddle" border="0" height="16" src="images/RESUME.GIF"
width="16" />
<a href="infor.do" target="right"><span style="color: #333333">个人信息</span></a></td>
</tr>
<tr style="color: #333333">
<td>
<img align="absMiddle" border="0" height="22" src="images/LASTBLK.GIF" width="16" /><img
align="absMiddle" border="0" height="16" src="images/EXIT.GIF" width="16" />
<a href="login.jsp" target="right"><span
style="color: #333333"> 退 出</span></a></td>
</tr>
</table>
<p>
<br />
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<八>一个简单的 不安全的 login .jsp
package com.suypower.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.suypower.db.DBCon;
public class LoginServlet extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
String userid=request.getParameter("userId");
String psw=request.getParameter("userMm");
HttpSession session=request.getSession();
session.setAttribute("userid",userid);
try{
Connection con=new DBCon().getConnection();
Statement stmt=con.createStatement();
String sql1="select count(User_ID) as zongshu from PJ_User where User_ID='"+userid+"' and User_MM='"+psw+"'";
ResultSet rs1=stmt.executeQuery(sql1);
rs1.next();
String noing=rs1.getString("zongshu");
if(noing.equals("0"))
{
RequestDispatcher rd=request.getRequestDispatcher("error.jsp");
rd.forward(request, response);
}else
{
RequestDispatcher rd=request.getRequestDispatcher("frameset.jsp");
rd.forward(request, response);
}
}catch(SQLException e)
{
e.printStackTrace();
}
}
}
FOR; 用struts + hibernate 验证用户 login .jsp
package com.suypower.struts;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import DBConnect.DBConn;
public class LoginAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws Exception
{
// System.out.print("11111111111111111111");
ActionForward actionForward=new ActionForward();
// LoginForm lf=(LoginForm)form;
// String userID=lf.getUserId();
// String userMM=lf.getUserMm();
// System.out.println("222222222222222222");
// String sql="from PjUser as pj where pj.userId=:PJuserId and pj.userMm=:PJuserMm";
// //判断用户
// System.out.print("3333333333333");
// try{
// Session session=HibernateSessionFactory.getSession();
// //HibernateSessionFactory.getSession();
// //new Configuration().configure().buildSessionFactory().openSession();
// System.out.println("44444444444444");
// Transaction tx=session.beginTransaction();
// System.out.println("5555555555555555");
// Query query=session.createQuery(sql);
// System.out.println("666666666666666666");
// query.setString("PJuserId", userID);
// query.setString("PJuserMm", userMM);
// tx.commit();
// System.out.println("777777777777777777777");
// if(query.list().size()>0)
// {
// session.close();
// return mapping.findForward("frameset");
// }
// else
// {
// return mapping.findForward("error");
// }
// }catch(HibernateException e)
// {
// e.printStackTrace();
// }
// return actionForward;
String userid=request.getParameter("userId");
String psw=request.getParameter("userMm");
HttpSession session=request.getSession();
session.setAttribute("userid",userid);
Connection con=new DBConn().getConnection();
// String sql="select User_ID,User_MM,Popedom_ID from PJ_User where User_ID='"+userid+"' and User_MM='"+psw+"'";
// System.out.print(sql);
Statement stmt=con.createStatement();
// ResultSet rs=stmt.executeQuery(sql);
// while(rs.next())
// {
// String name=rs.getString("User_ID");
// String password=rs.getString("User_MM");
// String popodomID=rs.getString("Popedom_ID");
// session.setAttribute("popodomID", popodomID);
// }
String sql1="select count(User_ID) as zongshu from PJ_User where User_ID='"+userid+"' and User_MM='"+psw+"'";
ResultSet rs1=stmt.executeQuery(sql1);
rs1.next();
String noing=rs1.getString("zongshu");
System.out.println("ddddddddddddddd"+noing);
if(noing.equals("0"))
{
System.out.println("wwwwwwwwwwwww"+rs1.getRow());
return actionForward=mapping.findForward("error");
}
if(rs1.getRow()>0)
{
System.out.println("sssssssssssssss"+rs1.getRow());
return actionForward=mapping.findForward("frameset");
}
return actionForward;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<九>: 一个地市 信息 显示 绑订到数据库 显示 连接 (联到删除 什么对应的 功能)
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="Test.SjbdDishi" %>
<html>
<body>
<div align="center">
<table>
<tr><th>统计信息:共有${count }个地市<th></tr>
</table>
<br>
<table width="75%" border=1>
<tr><th>地市</th><th>地市区号</th><th>查看</th></tr>
<%
SjbdDishi ds=new SjbdDishi();
ds.getDSsjbd(request,out);
%>
</table>
</div>
</body>
</html>
package Test;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspWriter;
import DBConnect.DBConn;
public class SjbdDishi {
public void getDSsjbd(HttpServletRequest request,JspWriter out)
{
HttpSession session=request.getSession();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
DBConn db = new DBConn();
conn = db.getConnection();
stmt = conn.createStatement();
String sql = "select City_ID,City_NAME from dbo.PJ_City";
rs = stmt.executeQuery(sql);
while (rs.next())
{
int count=rs.getRow();
session.setAttribute("count", count);
String cityID=rs.getString("City_ID");
String cityNAME=rs.getString("City_NAME");
out.print("<tr><td>"+cityID+"</td><td>"+cityNAME+"</td>");
out.print("<td><a href=dsView.do?param="+rs.getString("City_ID")+">查看</a></td>");
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
}
}
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
jdbc 连接
package com.suypower.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBCon {
final private String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
final private String driverURL="jdbc:sqlserver://172.23.23.3:1433;databaseName=pjtest";
final private String username="pj";
final private String password="pj3023";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
public Connection getConnection()
{
try
{
Class.forName(driverName);
}catch(ClassNotFoundException e)
{
System.out.println("%%%连接驱动失败%%%");
e.printStackTrace();
}
try
{
con=DriverManager.getConnection(driverURL,username,password);
}catch(SQLException e)
{
e.printStackTrace();
System.out.println("%%%连接数据库失败%%%");
}
finally
{
}
return con;
}
}
%%%%%%%%%%%%%%%%%%%%%%-2007-12-18-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
extremeComponents 的删除 和编辑弹出页面 实现
1。分页信息输出
<div align="center" id="cz" >
<ec:table
action="${pageContext.request.contextPath}/BmServlet"
items="arrayBM"
var="a"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
width="99%"
tableId="resultTable1"
rowsDisplayed="10"
form="frm"
filterable="false"
sortable="false"
autoIncludeParameters="false">
<ec:row>
<ec:column property="city_id" title="【所属地市】" width="16%"></ec:column>
<ec:column property="county_id" title="【分县公司】" width="16%"></ec:column>
<ec:column property="bm_id" title="【所属部门】" width="16%"></ec:column>
<ec:column property="person_id" title="【员工工号】" width="16%"></ec:column>
<ec:column property="person_name" title="【员工姓名】" width="16%"></ec:column>
<ec:column property="【编辑】" title="" width="10%">
<input type="button" value="编辑" name="space">
</ec:column>
<ec:column property="【删除】" title="" width="10%">
<input type="button" value="删除" onclick="del('${a.person_id }')">
</ec:column>
</ec:row>
</ec:table>
<input type="hidden" name="shanchu">
</div>
2。
。。。。
。。。
function del(person_id)
{
document.frm.change.value="shanchu";
document.frm.shanchu.value=person_id;
frm.submit();
}
</script>
3。servlet 获取参数 然后 连接数据库 执行删除
。。。
。。。。
if(param.equals("shanchu"))
{
String person_id=request.getParameter("shanchu");
//写SQL语句 删除
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
System.out.println(person_id);
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
编辑
思路:用分页组件 extremecomponents 实现 编辑
然后 传参数
用JS实现 弹出页面
页面上是用JSP
然后用的是 JS限制格式
JSP action=到 SERVLET
SERVLET 获取 参数
连接数据库 update 数据 即可
很清晰的思路哦
代码:
<div align="center" id="cz" >
<ec:table
action="${pageContext.request.contextPath}/BmServlet"
items="arrayBM"
var="a"
imagePath="${pageContext.request.contextPath}/images/table/*.gif"
width="99%"
tableId="resultTable1"
rowsDisplayed="10"
form="frm"
filterable="false"
sortable="false"
autoIncludeParameters="false">
<ec:row>
<ec:column property="city_id" title="【所属地市】" width="16%"></ec:column>
<ec:column property="county_id" title="【分县公司】" width="16%"></ec:column>
<ec:column property="bm_id" title="【所属部门】" width="16%"></ec:column>
<ec:column property="person_id" title="【员工工号】" width="16%"></ec:column>
<ec:column property="person_name" title="【员工姓名】" width="16%"></ec:column>
<ec:column property="【编辑】" title="" width="10%">
<input type="button" value="编辑" onclick="edit('${a.person_id }','${a.city_id }','${a.county_id }','${a.bm_id }','${a.person_name }')" >
</ec:column>
<ec:column property="【删除】" title="" width="10%">
<input type="button" value="删除" onclick="del('${a.person_id }')">
</ec:column>
</ec:row>
</ec:table>
<input type="hidden" name="shanchu">
</div>
....
...
function edit(person_id,city_id,county_id,bm_id,person_name)
{
url="edit.jsp?personid="+person_id+"&cityid="+city_id+"&countyid="+county_id+"&bmid="+bm_id+"&personName="+person_name;
//alert(url);
window.open(url,'newwindow','height=250,width=400,top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}
</script>
JSP
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<%
String personid=new String(request.getParameter("personid").getBytes("iso8859-1"),"gbk");
String cityid=new String(request.getParameter("cityid").getBytes("iso8859-1"),"gbk");
String countyid=new String(request.getParameter("countyid").getBytes("iso8859-1"),"gbk");
String bmid=new String(request.getParameter("bmid").getBytes("iso8859-1"),"gbk");
String personName=new String(request.getParameter("personName").getBytes("iso8859-1"),"gbk");
%>
<form action="EditServlet" method="post">
<table>
<tr><td>用户ID:</td><td><%= personid %></td></tr>
<tr><td>用户名:</td><td><%= personName %></td></tr>
<tr><td>城市:</td><td><%= cityid %></td></tr>
<tr><td>区县:</td><td><input type="text" value="<%= countyid %>" name="aaa"></td></tr>
<tr><td>部门:</td><td><input type="text" value="<%= bmid %>" name="bbb"></td></tr>
<tr>
<td>是否为服务人员:</td>
<td>
<select name="fuwu">
<option>是</option>
<option>否</option>
</select>
</td></tr>
<tr><td><input type="submit" value="确定"></td></tr>
</table>
</form>
</body>
</html>
Servlet
。。。。。。。。。
获取表单信息 写SQL 更新 即可 很简单的 这里就不给代码了
//////////////////////////////////////////////////2007-12-19//////////////////////////////////////////////////////////。。。。。。。。。。。。。。。AJAX 联动。。。。。。。。。。。。。。。
ajax
<%@ page language="java" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
This is my ajax JSP page. <br>
<head>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActionXObject)
{
xmlHttp=new ActionXObject("Microsoft.XMLHTTP");
}
elst if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
function startRequest()
{
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlRequest.open("get","innerHTML",true);
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
document.getElementById("results").innerHTML=xmlHttp.responseText;
}
}
}
}
</script>
</head>
<body>
<form action="#">
<input type="button" value="ajax" onclick="startRequest();"/>
<div id="results"></div>
</form>
</body>
</html>
innerHTML.xml
...
.....
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ajax 实现级联下拉 更新 数据库
<head>
<script language ="javascript">
var http_request = false;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{ //IE浏览器
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function Change_Select(){
var cityID=document.frm.city.value;
createXMLHttpRequest();
http_request.onreadystatechange=callback;
http_request.open("get","TestServlet?cityid="+cityID,true);
http_request.send(null);
}
function callback(){
if(http_request.readyState == 4)
{
if(http_request.status == 200)
{
var str=http_request.responseText;
if(str!=null)
{
var field=str.split("|");
}
document.getElementById("county").length=0;//调用之前先置为空
for(var i=0;i<field.length-1;i++)
{
var option=field[i].split(",");
document.frm.county.add(new Option(option[0],option[0]));
}
}else {
alert("http_request.status == 200 失败");
}
}
}
</script>
</head>
<body>
<form name="frm" action="YwlServlet" method="post">
.......................
<select name="city" onChange="Change_Select()">
<option>==请先选择地市==</option>
<option value="025">南京</option>
<option value="0511">镇江</option>
<option value="0519">常州</option>
....................
.................
...
<td>
<select name="county">
<option>==所有区县==</option>
</select>
</td>
..............
servlet
...
..
package com.suypower.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.suypower.db.DBCon;
public class TestServlet extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
response.setContentType("text/html");
response.setCharacterEncoding("gb2312");
doPost(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
//String cityID=request.getParameter("cityid");
Connection con=null;
Statement stmt=null;
PrintWriter out=response.getWriter();
request.setCharacterEncoding("gb2312");
response.setContentType("text/html");
response.setCharacterEncoding("gb2312");
try{
con=new com.suypower.db.DBCon().getConnection();
stmt=con.createStatement();
String sql="select county_name from pj_county";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
String county_name=rs.getString("county_name");
out.print(county_name+"|");
}
}catch(SQLException e){e.printStackTrace();}
}
}
¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
程雨__级联菜单__树型结构
不要着急 我们 来 先看看API
Overview
Functions
add
openAll
closeAll
openTo
Configuration
Functions
add()
Adds a node to the tree.
Can only be called before the tree is drawn.
id, pid and name are required.
Parameters
Name Type Description
id Number Unique identity number.
pid Number Number refering to the parent node. The value for the root node has to be -1.
name String Text label for the node.
url String
发表评论
-
java 生成 验证码
2012-09-04 17:05 4672<script type="text/ja ... -
读取 properties
2012-08-21 17:19 1242import java.io.File; import ja ... -
eXtremeComponents 分页列表
2012-08-03 09:25 1728<%@taglib uri="/WEB-INF ... -
Map套map 前台jstl遍历
2012-08-02 10:56 2298public String queryAdminPoped ... -
MD5加密
2012-07-19 17:08 1126public class MD5psw { /** * M ... -
CSVReader
2012-07-03 08:49 9040package com.zte.nva.dap.hadoop. ... -
java调用linux shell命令
2012-06-20 19:06 2043/** * 调用shell命令,创建android ... -
反编译插件jad安装 MyEclipse8.5
2012-04-23 10:45 1382准备工作 下载jad.exe文件:http://www ... -
强化不可实例化能力
2011-09-28 15:54 883有时候我们会编一些只含有静态域和静态方法的类,用私有构造函数强 ... -
持续集成环境配置
2011-09-27 10:58 863见附件 见附件 -
Serializable demo
2011-09-23 14:45 1004/** * serialization 序列化 * s ... -
junit4 @test DEMO
2011-09-15 16:15 5273package com.isoftstone.ecc.juni ... -
重写@Override toString
2011-07-20 14:30 1668/** * UserBean.java * com ... -
request.getParameterNames()和request.getParameterValues()
2011-06-09 16:38 4493request.getParameterNames()和r ... -
java基础の解析 map
2011-05-19 14:06 1543package com.csdn; import jav ... -
java Swing 的excel 操作 -导入导出 (原型)
2011-04-14 17:01 4674package com.excel; import ... -
java 发送EMAIL邮件
2011-04-14 15:56 1039import java.util.Date; import ... -
java和JSTL遍历map
2011-04-14 15:50 1338public Map<Integer,List<M ... -
MyEclipseGen
2011-03-12 11:26 1021myeclipse的激活码自动生成 import java.i ... -
TimerTask
2011-03-01 21:42 1203import java.util.Timer; import ...
相关推荐
5. **市场规模预测**:易观国际预计2010年手机游戏市场规模将达95亿,空中网2008年的收入突破2千万,其中手机游戏包括单机游戏和在线网游,后者通过虚拟道具收费。 **市场问题** 1. **社交网络(SNS)局限性**:...
而“2008年1月1日 随笔档案 - Liugang的博客 - 博客园.mht”可能包含了一些个人的开发经验或技巧,也有可能与connection连线的实现有关。 综合以上信息,我们可以深入探讨connection连线样式的实现,包括但不限于...
本书由国际发展研究中心(IDRC)和东南亚研究院(ISEAS)联合出版,旨在探讨亚洲背景下电子商务的发展与实践。IDRC自1970年起,致力于通过科学技术解决发展中国家的社会、经济和环境问题。书中详细介绍了IDRC的ICT4D项目,以及如何通过项目如Acacia、泛亚网络和泛美项目,在非洲、亚洲和拉丁美洲推动信息通信技术(ICTs)的影响力。特别强调了IDRC在弥合数字鸿沟方面所作出的贡献,如美洲连通性研究所和非洲连通性项目。ISEAS作为东南亚区域研究中心,专注于研究该地区的发展趋势,其出版物广泛传播东南亚的研究成果。本书还收录了电子商务在亚洲不同国家的具体案例研究,包括小型工匠和开发组织的电子商务行动研究、通过互联网直接营销手工艺品、电子营销人员的创新方法以及越南电子商务发展的政策影响。
少儿编程scratch项目源代码文件案例素材-Leap On.zip
内容概要:本文详细介绍了ANSYS Maxwell电磁仿真软件在高速无刷电机(特别是吸尘器电机)设计中的应用。主要内容涵盖电机设计中的常见挑战及其解决方案,如定子槽开口设计、气隙磁密控制、Halbach阵列的应用、定子斜槽角度选择、散热设计以及PWM控制策略等。文中通过具体实例展示了如何利用Maxwell进行参数化扫描、瞬态场仿真、温度场耦合仿真等操作,从而优化电机性能并提高效率。此外,还讨论了仿真与实际情况之间的差异及应对措施。 适合人群:从事电机设计、电磁仿真及相关领域的工程师和技术人员。 使用场景及目标:适用于希望深入了解高速无刷电机设计原理及优化方法的专业人士。目标是在实际项目中运用Maxwell电磁仿真工具,解决设计难题,提升产品性能。 其他说明:文章强调了仿真并非万能,但合理的仿真手段能够极大促进产品研发进程。文中提供了多个实用的Python和MATLAB脚本示例,帮助读者更好地理解和应用相关技术。
这是我记录的第一篇笔记和博客,我现在大一下,我想以此为契机激励自己记笔记,加深对特定知识的印象!目前我在学习黑马的Java,同时期也会学一些数据结构和相关算法,我也会将这部分笔记上传。最后我想说的是一些最近的感想 1.不要美化你没走过的路 2.来都来了那就坚持走下去,不给自己留遗憾!!
内容概要:本文详细介绍了如何利用Matlab构建并训练双输入深度学习模型,特别是针对不同长度的一维序列数据(如时序信号及其FFT频谱)。首先,作者展示了如何生成用于实验的仿真数据,接着深入探讨了网络架构的设计思路,包括采用CNN-LSTM处理时序特征以及纯CNN提取频域特征的方式。文中强调了数据预处理的重要性,如归一化处理,并提供了具体的训练选项设置方法。此外,还分享了一些实用的小贴士,如如何正确地进行模型评估和调整网络结构以适应不同的应用场景。最后,作者提到了一些常见的错误及解决办法,帮助读者避开潜在的陷阱。 适合人群:对深度学习感兴趣的科研工作者、研究生及以上水平的学生,尤其是那些希望将理论应用于实践的人群。 使用场景及目标:适用于需要同时处理多种类型数据的研究项目,如机械故障诊断、情感分析等领域。通过本教程的学习,读者能够掌握构建高效双输入深度学习模型的方法,从而提高数据分析的效果。 其他说明:本文不仅提供完整的代码示例,还包括了许多实践经验分享,有助于初学者更好地理解和应用所学知识。
内容概要:本文详细介绍了使用COMSOL进行三相电力变压器温度场与流体场耦合计算的具体步骤和技术要点。首先讨论了变压器温升问题的重要性和现有仿真与实测数据之间的偏差,接着阐述了电磁-热-流三场耦合建模的难点及其解决方法。文中提供了关键的材料属性设置代码,如变压器油的密度和粘度随温度变化的关系表达式,并强调了网格划分、求解器配置以及后处理阶段需要注意的技术细节。此外,还分享了一些实用的经验和技巧,例如采用分离式步进求解策略、优化网格划分方式等,确保模型能够顺利收敛并获得精确的结果。最后,作者推荐了几种常用的湍流模型,并给出了具体的参数设置建议。 适用人群:从事电力系统设计、变压器制造及相关领域的工程师和技术人员,特别是那些希望深入了解COMSOL软件在复杂多物理场耦合计算方面应用的人群。 使用场景及目标:适用于需要对变压器内部温度分布和油流情况进行精确模拟的研究或工程项目。主要目的是提高仿真精度,使仿真结果更加贴近实际情况,从而指导产品设计和优化运行参数。 其他说明:文中不仅包含了详细的理论解释和技术指导,还提供了一些实际案例供读者参考。对于初学者来说,可以从简单的单相变压器开始练习,逐步掌握复杂的三相变压器建模技能。同时,作者提醒读者要注意单位的一致性和材料属性的准确性,这是避免许多常见错误的关键所在。
PSD信号处理电路(PCB 原理图 封装库)亲测可用.zip
少儿编程scratch项目源代码文件案例素材-3D游戏.zip
信号分析,可导入外部信号文件 分析信号合成频率。 也可设置信号频率合成信号源。 信号合成,可导入外部频率文件 合成信号数据。也可调整频率数值合成信号源。 应用于通信领域, 光学领域,声波领域,信号和频率通过图形进行展示,所见所得,
少儿编程scratch项目源代码文件案例素材-3D 汽车.zip
内容概要:本文详细介绍了永磁同步电机(PMSM)基于磁场定向控制(FOC)的四种不同控制策略及其Simulink仿真模型。首先,经典双闭环PI控制提供了稳定的基础控制方式,适用于大多数应用场景。其次,电流滞环控制采用Bang-Bang控制策略,虽然响应速度快但能耗较高。第三种方法是滑模转速控制,利用非线性切换函数提高系统的抗扰动能力,但在稳态时存在轻微抖振。最后,PR控制在静止坐标系上实现了高精度的电流跟踪,特别适合固定频率应用。每种控制方法都有详细的参数设定和仿真波形展示,帮助读者深入理解各控制策略的特点和适用范围。 适合人群:从事电机控制系统研究与开发的技术人员,尤其是有一定MATLAB/Simulink基础的研发人员。 使用场景及目标:①掌握永磁同步电机FOC控制的基本原理和技术细节;②通过具体实例和仿真模型验证不同控制策略的效果;③选择最适合特定应用场景的控制方法并进行优化。 其他说明:文中还提到了一些实用技巧,如参数调整的经验法则、常见问题的解决方案以及仿真环境配置注意事项。附带的参考文献有助于进一步深入了解相关理论背景。
内容概要:本文详细介绍了利用模型预测控制(MPC)实现无人艇分布式编队协同控制的方法和技术。首先,通过简化的动力学模型和MATLAB代码展示了无人艇的基本行为预测。接着,深入探讨了编队协同控制的关键要素,包括代价函数的设计、信息交换机制以及分布式MPC的具体实现步骤。文中还提供了具体的Python代码示例,涵盖了从单个无人艇的动力学建模到多智能体之间的协作控制。此外,作者分享了一些实用技巧,如如何处理通信延迟、传感器噪声等问题,并展示了仿真效果,证明了所提出方法的有效性和鲁棒性。 适合人群:对无人艇编队控制、模型预测控制(MPC)、分布式系统感兴趣的科研人员、工程师及高校学生。 使用场景及目标:适用于研究和开发无人艇编队控制系统,特别是希望通过分布式控制实现高效、灵活的编队任务。目标是在复杂的海洋环境中,使无人艇能够自主完成编队、跟踪指定路径并应对各种干扰因素。 其他说明:文中提供的代码片段和理论解释有助于理解和实现无人艇编队控制的实际应用。建议读者在实验过程中结合实际情况进行参数调整和优化。
内容概要:本文详细介绍了两种成熟的220V转12V工业电源设计方案,分别是6W和12W的反激式电源设计。文中不仅提供了详细的电路设计参数,如变压器绕制方法、元件选择、PCB布局技巧,还分享了许多实用的经验和技术细节,确保设计方案能够顺利通过相关认证。同时,文章对比了两种方案的成本和性能差异,帮助读者在实际应用中做出合适的选择。 适合人群:从事电源设计的工程师,尤其是对220V转12V工业电源设计感兴趣的初学者和有一定经验的研发人员。 使用场景及目标:适用于需要将220V交流电转换为12V直流电的应用场合,如工业设备、智能家居、医疗设备等。目标是提供高效、稳定且成本可控的电源解决方案。 其他说明:文章强调了变压器设计和EMI测试中的注意事项,以及如何在保证性能的前提下降低成本。此外,还提到了一些常见的认证问题及其解决办法。
内容概要:本文探讨了基于储能电站服务的冷热微网系统双层优化模型,旨在解决储能配置和运行调度在不同时间尺度下的优化问题。文中首先介绍了双层规划模型的构建,上层负责长时间尺度的储能配置,涉及储能系统的容量、充放电功率等关键参数;下层则专注于短时间尺度的微网优化运行,涵盖太阳能、风力发电等能源设备的功率输出。接着,文章阐述了如何通过KKT条件将双层模型转化为单层模型,并使用大M法将其线性化处理,以便于求解。最后,通过使用Gurobi等求解器进行求解,实现了储能系统的优化配置和高效运行。 适合人群:从事能源领域的研究人员和技术人员,尤其是对储能系统和微网优化感兴趣的读者。 使用场景及目标:适用于需要优化储能配置和微网运行的企业或研究机构,目标是提高能源利用效率,降低成本,促进可持续能源的发展。 其他说明:文章提供了详细的Python代码示例,帮助读者理解和实现双层优化模型的具体步骤。此外,还讨论了一些实际应用中的注意事项,如大M值的选择和求解器的配置等。
内容概要:本文介绍了永磁同步电机(PMSM)的最大转矩电流比(MTPA)控制和弱磁控制的MATLAB/Simulink仿真模型及其设计原理。首先阐述了这两种控制方式的背景和技术意义,接着详细解释了MTPA控制和弱磁控制的具体实现方法,包括关键公式和代码片段。然后展示了如何在Simulink中构建完整的仿真模型,涵盖各个控制模块的搭建,如电流环、速度环的PI调节器等。最后通过仿真结果分析验证了所提出的控制策略的有效性和优越性。 适合人群:从事电机控制系统研究的技术人员、高校相关专业师生、对永磁同步电机控制感兴趣的工程技术人员。 使用场景及目标:适用于需要深入了解并掌握永磁同步电机高性能控制技术的研究人员,帮助他们理解和实现高效的电机控制策略,特别是在工业自动化、电动汽车等领域。 其他说明:文中提供了详细的代码示例和仿真波形图,有助于读者更好地理解和复现实验结果。同时指出了调试过程中可能遇到的问题及解决方案,便于初学者避免常见错误。
内容概要:本文详细介绍了利用Matlab/Simulink进行异步电机调速仿真的具体实现方法。首先探讨了最经典的恒压频比(V/F)开环控制系统,通过设置三相电源模块、V/F控制器和SVPWM逆变器,实现了电压和频率的线性增长,展示了开环系统在不同负载情况下的性能特点。接着引入了更为复杂的转差频率闭环控制方案,通过加入转速外环和转差频率内环,以及PID调节器,显著提高了系统的稳定性,特别是在负载突变时的表现。最后讨论了SVPWM控制的优势,强调其在改善电压波形质量和降低谐波方面的优越性。 适合人群:从事电机控制领域的研究人员和技术人员,尤其是有一定Matlab/Simulink基础的工程师。 使用场景及目标:适用于需要深入了解异步电机调速原理和仿真实现的研究项目。主要目标是掌握V/F开环和转差频率闭环两种控制方式的具体实现步骤,理解各自的特点和应用场景,同时学会优化系统参数以提高性能。 其他说明:文中提供了详细的代码片段和仿真技巧,帮助读者更好地理解和应用相关理论。建议读者在实践中结合实际硬件参数进行调整,确保仿真结果的准确性。
内容概要:本文详细介绍了丰田Prius 2004永磁同步电机的设计流程和技术要点,涵盖了从初步设计到最终仿真的各个环节。首先,利用Excel进行初始参数计算,如定子叠厚、绕组匝数等,确保设计的基础合理性。接着,通过Maxwell有限元仿真进行参数化建模,优化磁钢尺寸、气隙长度等关键参数,并通过批处理脚本提高仿真效率。同时,借助橡树岭国家实验室提供的实测数据,验证仿真结果的准确性,确保材料属性和损耗计算的精确性。此外,MotorCAD用于温升仿真,设置合理的冷却系统参数,防止电机过热。最后,提供了详细的建模教程,帮助初学者避开常见错误。 适用人群:从事电机设计的工程师和技术人员,尤其是对永磁同步电机感兴趣的从业者。 使用场景及目标:适用于希望深入了解Prius 2004永磁同步电机设计的技术人员,旨在通过实际案例掌握从理论计算到仿真验证的完整设计流程,提升电机设计能力。 其他说明:文中不仅提供了具体的公式和代码示例,还分享了许多实用的实战经验和避坑指南,使读者能够更快地上手并应用到实际工作中。
内容概要:本文深入探讨了基于功率同步控制(PSC)的并网变流器在弱电网条件下的暂态稳定性。首先介绍了PSC的基本原理和核心算法,展示了如何通过相位图和小信号模型进行稳定性分析。文中详细解释了K_p和K_i参数对系统稳定性的影响,并提供了具体的Python和Matlab代码示例。接着讨论了弱电网环境中系统的特殊行为,如相位轨迹的发散与收敛,以及如何通过调整虚拟惯量J和阻尼系数D来提高系统的稳定性。最后分享了一些实际工程中的调试经验和技巧,强调了仿真与实测数据相结合的重要性。 适合人群:从事电力系统研究和开发的技术人员,特别是关注并网变流器稳定性和弱电网环境下的控制系统设计的专业人士。 使用场景及目标:适用于评估和改进并网变流器在弱电网条件下的性能,确保其在各种工况下的稳定运行。目标是帮助工程师理解和掌握PSC的工作机制,以便更好地应对实际工程项目中的挑战。 阅读建议:读者可以通过本文提供的代码示例和图表,结合自身的实践经验,逐步理解PSC的工作原理及其在弱电网环境下的表现。同时,应注意将理论分析与实际测量相结合,以获得更全面的认识。