使用连接沲配置
时间:2010-07-05 来源:mozhx
Context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context> <Resource name="jdbc/newspager" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000"
username="root" password="a12345"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/newspaper?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior=convertToNull" />
</Context> <%@ page contentType="text/html; charset=gbk" %> <%@ page language="java" import="java.util.*" pageEncoding="GB18030"%> <%@ include file="include.jsp" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %> ---------------------------------------- <display:table style="width:90%" class="mars" name="${requestScope['pagerList']}" partialList="true" size="${total}" pagesize="${pageSize}" requestURI="pager.do" export="true" id="gridlist" >
<display:column title="<input type=checkbox name=chkAll>"><input type="checkbox" name="chkDelete" id="chkDelete" value='${gridlist.id}'></display:column>
<display:column property="id" sortable="true" title="ID"></display:column>
<display:column property="name" sortable="true" title="报纸名称"></display:column>
<display:column property="price" sortable="true" title="单价"></display:column>
<display:column title="修改名称"><a href="#" onclick="openWin('pager.do?command=updateinput&id=${gridlist.id }','editPager',500,450);">修改</a></display:column>
</display:table> -------------------------------------- <pg:pager items="${total }" maxPageItems="${pageSize }" url="historyNumber.do" export="currentPageNumber=pageNumber">
<pg:param name="command" value="list" />
<pg:param name="userId" />
<pg:param name="pageSize" />
<pg:param name="pdate" />
<pg:first><a href="${pageUrl}">首页</a></pg:first>
<pg:prev><a href="${pageUrl }">前页</a></pg:prev>
<pg:pages>
<c:choose>
<c:when test="${ currentPageNumber eq pageNumber}">
<font color="red">${pageNumber}</font>
</c:when>
<c:otherwise>
<a href="${pageUrl }">${pageNumber }</a>
</c:otherwise>
</c:choose>
</pg:pages>
<pg:next><a href="${pageUrl }">下页</a></pg:next>
<pg:last><a href="${pageUrl }">尾页</a></pg:last> </pg:pager> ------------------------------------------- ---------------------------------- <select size="3" onchange="goto();" name="userlist" id="userlist" style="width:100px;">
<c:forEach items="${user}" var="u">
<option value="${u.userId }" >${u.userName }</option>
</c:forEach>
</select> <!-选择指定项-> document.getElementById("pageSize").options[1].selected=true; ---------------------------------- <script type="text/javascript" src="js/my.js"></script> my.js //Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
}
}
function createAjaxObj(){
var httprequest=false
if (window.XMLHttpRequest)
{ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject)
{ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}else {
alert("Your Browser don't support ajax");
}
return httprequest
}
//Our XmlHttpRequest object to get the auto suggest
var searchReq = createAjaxObj(); //Called from keyup on the search textbox.
//Starts the AJAX request.
function doRequestUsingGET(url,handleStateChange) {
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
searchReq.open("GET", url, true);
searchReq.onreadystatechange = handleStateChange;
searchReq.send(null);
}
} function handleDefault() {
if(searchReq.readyState == 4){
if(searchReq.status == 200){}
}
} 调用ajax的js函数: function updateNumber(obj) {
var url = "HistoryNumberServlet?id="+obj.tid+"&actualAmount="+obj.value+"&operator=amount";
doRequestUsingGET(url,handleDefault);
priceTotal();
} onclick="javascript:window.location.href='pager.do?command=addinput';" -------------------------- function openWin(f,n,w,h,s){
sb = s == "1" ? "1" : "0";
l = (screen.width - w)/2;
t = (screen.height - h)/2;
sFeatures = "left="+ l +",top="+ t +",height="+ h +",width="+ w
+ ",center=0,scrollbars=" + sb + ",status=0,directories=0,channelmode=0";
openwin = window.open(f , n , sFeatures );
/*
if (!openwin.opener)
openwin.opener = self;
openwin.focus();
*/
return openwin;
}
function chkDel(){
var flag = false;
for (var i = 0; i < document.getElementsByName("chkDelete").length; i++) {
if (document.getElementsByName("chkDelete")[i].checked) {
flag = true;
}
}
if (!flag) {
alert("请选择需要删除的报纸!");
return;
}
if(confirm("确定要删除?")){
with(document.getElementById("form1")){
method = "post";
action = "pager.do?command=del";
submit();
}
}
}
<Context> <Resource name="jdbc/newspager" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000"
username="root" password="a12345"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/newspaper?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior=convertToNull" />
</Context> <%@ page contentType="text/html; charset=gbk" %> <%@ page language="java" import="java.util.*" pageEncoding="GB18030"%> <%@ include file="include.jsp" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %> ---------------------------------------- <display:table style="width:90%" class="mars" name="${requestScope['pagerList']}" partialList="true" size="${total}" pagesize="${pageSize}" requestURI="pager.do" export="true" id="gridlist" >
<display:column title="<input type=checkbox name=chkAll>"><input type="checkbox" name="chkDelete" id="chkDelete" value='${gridlist.id}'></display:column>
<display:column property="id" sortable="true" title="ID"></display:column>
<display:column property="name" sortable="true" title="报纸名称"></display:column>
<display:column property="price" sortable="true" title="单价"></display:column>
<display:column title="修改名称"><a href="#" onclick="openWin('pager.do?command=updateinput&id=${gridlist.id }','editPager',500,450);">修改</a></display:column>
</display:table> -------------------------------------- <pg:pager items="${total }" maxPageItems="${pageSize }" url="historyNumber.do" export="currentPageNumber=pageNumber">
<pg:param name="command" value="list" />
<pg:param name="userId" />
<pg:param name="pageSize" />
<pg:param name="pdate" />
<pg:first><a href="${pageUrl}">首页</a></pg:first>
<pg:prev><a href="${pageUrl }">前页</a></pg:prev>
<pg:pages>
<c:choose>
<c:when test="${ currentPageNumber eq pageNumber}">
<font color="red">${pageNumber}</font>
</c:when>
<c:otherwise>
<a href="${pageUrl }">${pageNumber }</a>
</c:otherwise>
</c:choose>
</pg:pages>
<pg:next><a href="${pageUrl }">下页</a></pg:next>
<pg:last><a href="${pageUrl }">尾页</a></pg:last> </pg:pager> ------------------------------------------- ---------------------------------- <select size="3" onchange="goto();" name="userlist" id="userlist" style="width:100px;">
<c:forEach items="${user}" var="u">
<option value="${u.userId }" >${u.userName }</option>
</c:forEach>
</select> <!-选择指定项-> document.getElementById("pageSize").options[1].selected=true; ---------------------------------- <script type="text/javascript" src="js/my.js"></script> my.js //Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
}
}
function createAjaxObj(){
var httprequest=false
if (window.XMLHttpRequest)
{ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject)
{ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}else {
alert("Your Browser don't support ajax");
}
return httprequest
}
//Our XmlHttpRequest object to get the auto suggest
var searchReq = createAjaxObj(); //Called from keyup on the search textbox.
//Starts the AJAX request.
function doRequestUsingGET(url,handleStateChange) {
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
searchReq.open("GET", url, true);
searchReq.onreadystatechange = handleStateChange;
searchReq.send(null);
}
} function handleDefault() {
if(searchReq.readyState == 4){
if(searchReq.status == 200){}
}
} 调用ajax的js函数: function updateNumber(obj) {
var url = "HistoryNumberServlet?id="+obj.tid+"&actualAmount="+obj.value+"&operator=amount";
doRequestUsingGET(url,handleDefault);
priceTotal();
} onclick="javascript:window.location.href='pager.do?command=addinput';" -------------------------- function openWin(f,n,w,h,s){
sb = s == "1" ? "1" : "0";
l = (screen.width - w)/2;
t = (screen.height - h)/2;
sFeatures = "left="+ l +",top="+ t +",height="+ h +",width="+ w
+ ",center=0,scrollbars=" + sb + ",status=0,directories=0,channelmode=0";
openwin = window.open(f , n , sFeatures );
/*
if (!openwin.opener)
openwin.opener = self;
openwin.focus();
*/
return openwin;
}
function chkDel(){
var flag = false;
for (var i = 0; i < document.getElementsByName("chkDelete").length; i++) {
if (document.getElementsByName("chkDelete")[i].checked) {
flag = true;
}
}
if (!flag) {
alert("请选择需要删除的报纸!");
return;
}
if(confirm("确定要删除?")){
with(document.getElementById("form1")){
method = "post";
action = "pager.do?command=del";
submit();
}
}
}
相关阅读 更多 +