调用天气:
<iframe
src="http://www.thinkpage.cn/weather/weather.aspx?uid=&c=CHXX0008&l=zh-CHS&p=CMA&a=1&u=C&s=1&m=1&x=1&d=2&fc=&bgc=&bc=&ti=1&in=1&li=2&ct=iframe"
frameborder="0" scrolling="no" allowTransparency="true"
style="width: 180px; height: 260px"></iframe>
//将list转化为数组
List mssxhlist=new ArrayList();
mssxhlist.add(value);
Long[] array = (Long[]) mssxhlist.toArray(new Long[mssxhlist.size()]);
select qjd_lsh,qjd_jqlx,qjd_sy,qjd_ygjs,jbxx_sszz from qjd,ygjbxx where qjd_ygbh = jbxx_bh and qjd_lsh = (select max(qjd_lsh) from qjd where qjd_ygbh = ?)");
while (rs.next()) {
po.setLsh(0);
po.setJqlx(rs.getString(2[c1] ));
po.setSy(rs.getString(3));
po.setYgjs(rs.getString(4));
po.setSszz(rs.getString(5));
}
/**获取当前登录人*/
User user=WebRBACRequestContext.getRBACRequestContext(request).getRequestUser();
String userName=user.getLoginName();
//避免重复提交
1、初始化方法中:
try {
saveToken(request);//Action类中自带
}
2、 保存方法中
try {
if (isTokenValid(request, true)) {
ztbgGjylBO.saveGjyl(ztbgGjylForm);
this.printSuccess(request,"","com.cvicse.message.saveSuccess");
} else {
saveToken(request);
this.printSuccess(request, "","com.cvicse.message. saveSuccess ");
}
}
//Map使用
Map<String, String> map = new HashMap<String, String>();
map.put(rs.getString(2), rs.getString(1));
//调tomcat内存
rem ----- Execute The Requested Command ---------------------------------------
set JAVA_OPTS=%JAVA_OPTS% -server -XX:PermSize=128m -XX:MaxPermSize=512m
//下载已有文件
直接将超链接地址配成要下载文件地址如:下载word 文档 :/zxks/zxksCzsm.doc
//Excle导入和导出、word导出
一、excel批量导入
1、---jsp
// 检测上传的文件的大小,类型是否正确
function checkFile(){
var filename = document.getElementById("file").value;
if("" == filename || null == filename){
alert("您还没有浏览要上传的文件!");
return false;
}else{
var ftype = filename.substring(filename.length - 4, filename.length);
if(".xls" != ftype){
alert("您上传的文件类型不正确,只能上传.xls的文件!");
return false;
}
}
return true;
}
// 清空
function clear1(){
document.getElementById("form1").reset();
}
// 帮助
function help(){
url = "<%=path%>/zxks/tkgl/stHelp.jsp";
window.open(url,'','');
}
<script type="text/javascript" for="window" event="onload">
var msg = '<%=message%>';
if("null" != msg && "" != msg){
if("ok" == msg){
alert("Excel批量导入数据成功!");
}else{
alert(msg);
}
}
</script>
<html:form action="/zxks/tkgl.do" method="post" styleId="form1" enctype="multipart/form-data">//一定不能忘
二、//excel批量导出
function excelExport(){
var tx=document.getElementById("tx");
var nd=document.getElementById("nd");
var kybz=document.getElementById("kybz");
var zsjnx=document.getElementById("jnxx_jnbh");
var tmNrx=document.getElementById("tmNrx");
var stlsh1=document.getElementById("stlshQo");
var ssbm=document.getElementById("bmbh");
var stzsd=document.getElementById("jnxx_zsdbh");
if (window.confirm("您确定要批量导出吗?")) {
with(document.forms[0]){
window.open('/cvicdns/zxks/zxks/tkgl.do?operFlag=queryOther&tx='+tx.value
+'&nd='+nd.value+'&kybz='+kybz.value+'&zsjn='+zsjnx.value+'&tmNr='+tmNrx.value+'&stlsh='+stlsh1.value+'&stzsd='+stzsd.value+'&ssbm='+ssbm.value);
return true;
}
}else{
return false;//ygxxzhcx导出查看
}
}
//word批量导出
function wordExport(){
var tx=document.getElementById("tx");
var nd=document.getElementById("nd");
var kybz=document.getElementById("kybz");
var zsjnx=document.getElementById("jnxx_jnbh");
var tmNrx=document.getElementById("tmNrx");
var stlsh1=document.getElementById("stlshQo");
var ssbm=document.getElementById("bmbh");
var stzsd=document.getElementById("jnxx_zsdbh");
if (window.confirm("您确定要批量导出吗?")) {
with(document.forms[0]){
window.open('/cvicdns/zxks/zxks/tkgl.do?operFlag=query1&tx='+tx.value
+'&nd='+nd.value+'&kybz='+kybz.value+'&zsjn='+zsjnx.value+'&tmNr='+tmNrx.value+'&stlsh='+stlsh1.value+'&stzsd='+stzsd.value+'&ssbm='+ssbm.value);
return true;
}
}else{
return false;
}
}
popup
jsp:
跳转链接:/rlzygl/ygxxgl/ygjbxxgl/selectYg.jsp?ryzk=?&zzjg=?
selectYg.jsp
<%@ page language="java" pageEncoding="GBK"%>
<%@ page import="com.cvicse.rlzygl.ygxxgl.dao.*"%>
<%@ page import="com.cvicse.rlzygl.ygxxgl.vo.*,java.util.*"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/cvicse-param.tld" prefix="param"%>
<%@ taglib uri="/WEB-INF/cvicse-common.tld" prefix="common"%>
<%@ include file="/cvicdns/public/noCache.jsp"%>
<%
String parentElementId = request.getParameter("parentElementId");
String sszz = (String) request.getParameter("zzjg");
String ryzk = (String) request.getParameter("ryzk");
List<YgjbxxPO> ygjbxxPOList = new ArrayList<YgjbxxPO>();
try {
YgjbxxglDAO ygjbxxglDAO = YgxxglDAOFactory.getYgxxglDAOFactory().getYgjbxxglDAO();
ygjbxxPOList = ygjbxxglDAO.getYgjbxxPO(ryzk,sszz);
} catch (Exception e) {
out.print(e.getMessage());
}
int si = ygjbxxPOList.size();
%>
<html>
<head>
<common:theme />
<script language='JavaScript'>
function clickJs(cybh,cymc){
var returnValue = new Object();
returnValue.id=cybh;
if( cybh == "" || cybh == null){
returnValue.name= cybh + cymc ;
}else{
returnValue.name= cymc+"<" + cybh + ">" ;
}
window.returnValue=returnValue;
window.parent.floatWindow<%=parentElementId%>.returnValue=returnValue;
window.parent.floatWindow<%=parentElementId%>.hidden();
}
function clear1(){
if(document.getElementById("selectText").value=="输入筛选条件"){
document.getElementById("selectText").value="";
document.getElementById("selectText").style.color="black";
}
}
function set1(){
if(document.getElementById("selectText").value==""){
document.getElementById("selectText").value="输入筛选条件";
document.getElementById("selectText").style.color="";
}
}
function sel(){
var length1 = <%=si%>;
var selectText = document.getElementById("selectText").value;
var td1 = null;
var tr1 = null;
for (var i = 0 ;i<length1;i++){
tr1 = document.getElementById(i);
td1 = tr1.childNodes[0];
if((td1.innerText).indexOf(selectText)<0){
tr1.style.display="none";
}else{
tr1.style.display="";
}
}
}
</script>
</head>
<body>
<table>
<tr>
<td bordercolor="red" background="green"><font color="black">输入<Strong>姓名或员工<br/>号</Strong>进行模糊匹配<br/></font>
<input type="text" onkeyup="sel()" id="selectText" maxlength="6" onblur="set1()"
value="输入筛选条件" onfocus="clear1()" size="12" style="" >
</td>
</tr>
</table>
<table border="0">
<tr id="0">
<%
for (int i = 0; i < si; i++) {
%>
<td
onMouseOver=" this.style.cursor='hand';this.style.backgroundColor='#99E2FB' "
onclick="clickJs('<%=ygjbxxPOList.get(i).getJbxxBh()%>','<%=ygjbxxPOList.get(i).getJbxxName().trim()%>')"
style="text-align: left; font-size: 12; color: blue"
nowrap="nowrap" onmouseout="this.style.backgroundColor=''">
<%=ygjbxxPOList.get(i).getJbxxName().trim()%><<%=ygjbxxPOList.get(i).getJbxxBh()%>>
</td>
</tr>
<tr id="<%=i + 1%>">
<%
}
%>
</tr>
</table>
</body>
</html>
//发送邮件
/**
* 审批发送邮件
*
* @param spjs
* @param bgdbh
* @return flag
* @throws DataAccessException
* @throws SQLException
* @throws Exception
*/
public boolean sendEmail(String spjs, String bgdbh)
throws DataAccessException, SQLException, Exception {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
// 声明日志对象
Logger logger = Logger.getLogger(XmjhbgDAO.class);
boolean flag = false;
String fsdx = "";// 发送对象
String csdx = "";// 抄送对象
String subject = "";// 邮件主题
String content = "";// 邮件内容
// 查询审批人邮件SQL
String sprEmailSQL = "select jscy_ygh ygbh,llfs_email email from llfs l,xm_xmbg_spjscy s "
+ "where l.llfs_ygdh=s.jscy_ygh and llfs_email is not null and s.jscy_jsbh='"
+ spjs + "'";
// 查询抄送邮件对象
String csEmailSQL = "select spjs_email email from xm_xmbg_spjs where spjs_bh='"
+ spjs + "'";
// 项目信息和变更次数
String conSQL = "select trim(x.xmbh) xmbh,trim(x.xmmc) xmmc,b.bgcs bgcs,b.bgms bgms from xm_xmbg_bgd b,kp_xmzd x where x.inid=b.inid and b.bgdbh='"
+ bgdbh + "'";
try {
conn = JDBCDataSource.getJDBCDataSource("jdbc.informix")
.getConnection();
ps = conn.prepareStatement(sprEmailSQL);
rs = ps.executeQuery();
while (rs.next()) {
fsdx = fsdx + rs.getString("email") + ";";
}
logger.debug("1、发送对象邮箱查询成功:" + fsdx);
ps = conn.prepareStatement(csEmailSQL);
rs = ps.executeQuery();
while (rs.next()) {
csdx = csdx + rs.getString("email") + ";";
}
logger.debug("2、抄送对象邮箱查询成功:" + csdx);
String[] to = fsdx.split(";");
String[] cs = csdx.split(";");
ps = conn.prepareStatement(conSQL);
rs = ps.executeQuery();
while (rs.next()) {
subject = "项目〈" + rs.getString("xmbh") + "〉"
+ rs.getString("xmmc") + " 第 " + rs.getString("bgcs")
+ " 次变更申请";
content = "<font face=黑体><strong>您好:</strong><br/> 项目<b>〈"
+ rs.getString("xmbh")
+ "〉"
+ rs.getString("xmmc")
+ "</b> 第 "
+ rs.getString("bgcs")
+ " 次变更需要您审批,变更描述如下:<br>"
+ bgmsFt(rs.getString("bgms"))
+ "<br>请登录数字神经审批。</font>";
}
logger.debug("3、邮件内容查询成功");
Properties props = new Properties(); // Properties p =
// System.getProperties();
props.put("mail.smtp.host", "smtp.qiye.163.com");// 存储发送邮件服务器的信息
props.put("mail.smtp.auth", "true");// 同时通过验证
props.put("mail.smtp.username", "dnaadmin@cvicse.com"); // 发件人的邮箱
props.put("mail.smtp.passwrod", "cvicseszsj321"); // 邮箱密码
// p.put("mail.smtp.port", "25");
// p.put("mail.smtp.auth", "true");
// p.put(" mail.transport.protocol", "smtp");
// p.put("mail.smtp.host", " smtp.asia-media.cn");
// p.put("mail.smtp.port", "25");
InternetAddress from = null; // 发件箱
from = new InternetAddress(props.get("mail.smtp.username")
.toString());
// 建立会话
Session session = Session.getInstance(props);
Message msg = new MimeMessage(session); // 建立信息
BodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
msg.setFrom(from); // 发件人
String toList = null;
String toListcs = null;
// String toListms = null;//密送
// 发送,
if (to != null) {
toList = getMailList(to);
InternetAddress[] iaToList = new InternetAddress()
.parse(toList);
msg.setRecipients(Message.RecipientType.TO, iaToList); // 收件人
}
// 抄送
if (cs != null) {
toListcs = getMailList(cs);// 获取抄送邮箱的列表
InternetAddress[] iaToListcs = new InternetAddress()
.parse(toListcs);
msg.setRecipients(Message.RecipientType.CC, iaToListcs); // 抄送人
}
/*
* // 密送 if (ms != null) { toListms = getMailList(ms);
* InternetAddress[] iaToListms = new InternetAddress()
* .parse(toListms); msg.setRecipients(Message.RecipientType.BCC,
* iaToListms); // 密送人 }
*/
msg.setSentDate(new Date()); // 发送日期
msg.setSubject(subject); // 主题
msg.setText(content); // 内容
// 显示以html格式的文本内容
messageBodyPart.setContent(content, "text/html;charset=gbk");
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
// 邮件服务器进行验证
Transport tran = session.getTransport("smtp");
// tran.connect(" smtp.asia-media.cn", "postmaster@ asia-media.cn",
// "asiamedia");
tran.connect(props.get("mail.smtp.host").toString(), props.get(
"mail.smtp.username").toString(), props.get(
"mail.smtp.passwrod").toString());
tran.sendMessage(msg, msg.getAllRecipients()); // 发送
flag = true;
} catch (DataAccessException e) {
flag = false;// 失败
e.printStackTrace();
throw new DataAccessException(e);
} catch (SQLException e) {
flag = false;// 失败
e.printStackTrace();
throw new SQLException(e.getMessage());
} catch (Exception e) {
flag = false;// 发送邮件失败
e.printStackTrace();
throw new Exception(e.getMessage());
}
return flag;
}
// 获取邮箱的列表,用逗号分开
private String getMailList(String[] mailArray) {
StringBuffer toList = new StringBuffer();
int length = mailArray.length;
if (mailArray != null && length < 2) {
toList.append(mailArray[0]);
} else {
for (int i = 0; i < length; i++) {
toList.append(mailArray[i]);
if (i != (length - 1)) {
toList.append(",");// 逗号正常,分号可能出现问题
}
}
}
return toList.toString();
}
Hibernate笔记
1、
Session session =
HibernateDataSource.getHibernateDataSource().getSession();
String hql = "from BaseHTestPO where name = :name";
Query query = session.createQuery(hql);
query.setString("name", "tom");
List<BaseHTestPO> list = query.list();
2、
String sql = "select * from htest where id='1'";
query = session.createSQLQuery(sql).addEntity(BaseHTestPO.class);
list = query.list();
3、
HibernateDataSource.getHibernateDataSource().remove(baseScqycplxsbPO);
性能测试:
测试工具:LoadRunner 11
测试技术:采用LoadRunner Virtual User Generator 录制编写测试脚本,
然后将脚本加入LoadRunner Controller 生成客户端负载向服务器发起负载压力测试,最后结合LoadRunner Analysis监控的过程性能数据,定位问题。
[c1]此处索引直接对应SQL语句中的查询出的字段,第一个索引字段从1开始