摘要:/**
* 获取数据库的所有列名和对应的数据库类型
* @param conn 连接数据库的对象 Connection conn= Jdb.openSQLDB(driver, url, user, password);
* @param sql 查询的表
* @return Map
*
*/
public static Map getColumnName(Connection conn,String sql){
Map map=new HashMap();
try {
PreparedStatement ps=conn.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
ResultSetMetaData rsm=rs.getMetaData();
while(rs.next()){
阅读全文
摘要:import org.springframework.web.util.HtmlUtils;
/**
* html特殊字符操作
* @param answer 操作default=转换为HTML转义字符表示;no=转换为数据转义表示;16转换为十六进制数据转义表示;否则为反向操作
* @param content要转换的内容
* @return
*/
public static String htmlOption(String answer,String content){
String con=content;
try {
if("default".equals(answer)){
con= HtmlUtils.htmlEscape(content);// ①转换为HTML转义字符表示
}else if("no".equals(answer)){
con = HtmlUtils.htmlEscapeDecimal(content); //②转
阅读全文
摘要:中文乱码过滤器
在您通过表单向服务器提交数据时,一个经典的问题就是中文乱码问题。虽然我们所有的 JSP 文件和页面编码格式都采用 UTF-8,但这个问题还是会出现。解决的办法很简单,我们只需要在 web.xml 中配置一个 Spring 的编码转换过滤器就可以了:
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter ① Spring 编辑过滤器
② 编码方式
encoding
param-v
阅读全文
摘要:/**
* md5加密
* @author admin
*/
public class MD5 {
private static final String ALGORITHM = "MD5";
private static char sHexDigits[] = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
private static MessageDigest sDigest;
static {
try {
sDigest = MessageDigest.getInstance(ALGORITHM);
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private MD5() {
}
//调用此方法,直
阅读全文
摘要:/**
* 将List转换成JSON字符串
*
* @param o
* @return
*/
public static String parseListMap2JSon(Object o) {
Gson gson = new GsonBuilder().create();
return gson.toJson(o, new TypeToken() {
}.getType());
}
/**
* 将JSON格式转换成Map
*
* @param json
* @return
*/
public static Map parseJSON2Map(String json) {
Map map = new HashMap();
Gson gson = new GsonBuilder().cre
阅读全文
摘要://去掉内容的标签
public static String removeTag(String count){
try {
int tagCheck=-1;
do {
int a = count.indexOf("");
int len = count.length();
String c=null;
c = count.substring(0, a);
if(b == -1)
b = a;
String d = count.substring((b + 1), len);
count = c + d;
tagCheck = count.indexOf("");
} while (tagCheck != -1);
} catch (Exception e) {
System.out.println("去掉内容标签异常,可能是该内容
阅读全文
摘要://发送邮箱
public static String sendEmail(String sendFrom,String sendTo,String passWord,String title,String count){
try{
String from =sendFrom.trim();//发送者
String to =sendTo.trim();//接受者
String subject =title.trim();//主题
String content =count.trim();//内容
String password =passWord.trim();//发送者邮箱密码
String path="null";//附件的路径
String mailserver ="smtp."+from.substring(from.indexOf('@')+1,from.length()); //在Internet上发送邮件时的代码(smtp服务器地址)
Properties prop =
阅读全文
摘要:response.setCharacterEncoding("UTF-8");
response.setContentType("text/html");
javax.servlet.ServletOutputStream ou = response.getOutputStream();
//文件名
// String filename=new String(fileName.getBytes("ISO8859_1"),"GB2312").toString();
//路径
java.io.File file = new java.io.File(urlandfile);
if (!file.exists()) {
System.out.println(file.getAbsolutePath() + " 文件不能存在!");
msg="unexists";
return msg;
}
// 读取文件流
阅读全文
摘要:MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("file");
// String name = multipartRequest.getParameter("name");
String realFileName = file.getOriginalFilename();
//System.out.println("获得文件名:" + realFileName); // 获取路径
String ctxPath = request.getSession().getServletContext().getRealPath("/") + "upload/"; // 创建文件
File dirPath = new File(ctxPath);
阅读全文
摘要:var url = location.href;
var browser_name = navigator.userAgent;
if(browser_name.indexOf('Chrome')!=-1){
alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“chrome://settings/browser”,进行主页设置。")
};
try {
this.style.behavior = "url(#default#homepage)";
this.setHomePage(url);
} catch (e) {
if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert("此操作被浏览器拒绝!\n请在
阅读全文
摘要:var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd': 'CTRL';
if (document.all) {
window.external.addFavorite(location.href, document.title)
} else if (window.sidebar) {
window.sidebar.addPanel(document.title, location.href, "")
} else {
alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~')
}
阅读全文
摘要:--------------------------数据库带实例名连接2008-------------------------------------
阅读全文
摘要:parent.location.href="";
parent.location.reload();
阅读全文
摘要:function getExplorerType() {
var explorer = window.navigator.userAgent ; //ie 浏览器
if (explorer.indexOf("MSIE") >= 0) {
alert("ie");
}
//firefox 火狐浏览器
else if (explorer.indexOf("Firefox") >= 0) {
alert("Firefox");
}
//Chrome 谷歌浏览器
else if(explorer.indexOf("Chrome") >= 0){
alert("Chrome");
}
//Opera 浏览器
else if(explorer.indexOf("Opera") >= 0)
{ alert("Opera");
}
//Safari else if(explorer.indexOf("Safari") >= 0){
alert("Safari")
阅读全文
摘要://解决浏览器问题
var count=document.documentElement.scrollTop+document.body.scrollTop;
var newheight=parseInt(count)+parseInt(110);
$("#im").attr("style","background-image:url('image/big_bg.png'); border:none; position:fixed; _position:absolute; z-index:99; margin-left:800px; padding: 3px; text-align: center; width:200px;height: 150px;top:"+newheight+"px;");
};
/* /*注册事件*/
if(document.addEventListener){
//mousewheel OR DOMMouseScroll
document.addEventListener('DOMMouseSc
阅读全文
摘要:stturs.xml:
struts2
org.apache.struts2.dispatcher.FilterDispatcher
struts2
/*
REQUEST FORWARD
阅读全文
摘要:var scrollFunc=function(e){
//获取函数代码
e=e || window.event;
//判断浏览器兼容哪个方法
if(e.wheelDelta)//IE/Opera/Chrome
alert("监听成功!");
else if(e.detail)//Firefox
alert("监听成功!");
}; /*注册事件*/
if(document.addEventListener) document.addEventListener('DOMMouseScroll',scrollFunc,false);//W3C
else
document.onmousewheel=scrollFunc;//IE/Opera/Chrome
阅读全文
摘要:Properties properties = new Properties();
try {
in=PublicFunctionUtil.class.getClass().getResourceAsStream(params.get("FileUrl").toString());//属性文件路径
if(in!=null||!"null".equals(in)){
in=Thread.currentThread().getContextClassLoader().getResourceAsStream(params.get("FileName").toString());//属性文件名
properties.load(in);
verCode=properties.getProperty(params.get("FileKey").toString());//属性文件的key值
}
in.close();
map.put("new
阅读全文
摘要:Stirng lsql="{call cp_bill_checkzf_pre @bmguid='',@operguid='')}";//存储过程
getComConn();
prstcomm = connection.prepareStatement(lsql);
rstcomm = prstcomm.executeQuery();//查询的方法(如果是更新就用executeUpdate)
if (rstcomm == null) {
return maps;
}
while (rstcomm.next() && rstcomm.getRow() 0) {
ResultSetMetaData metadata = rstcomm.getMetaData();
LinkedHashMap map = new LinkedHashMap();
for (int i = 1; i = metadata.getColumnCount(); i
阅读全文
摘要:String msg=null;
response.setCharacterEncoding("gb2312");
response.setContentType("text/html");
javax.servlet.ServletOutputStream ou = response.getOutputStream(); //文件名
String filename=new String(request.getParameter("filename").getBytes("ISO8859_1"),"utf-8").toString(); //路径
String filepath=ServletActionContext.getServletContext().getRealPath("/upload/"+filename);
java.io.File file = new java.io.File(filepath);
阅读全文
摘要:------------------------------下作下载方法二---------------------------------------------------
String msg=null;
try {
response.setCharacterEncoding("gb2312");
response.setContentType("text/html");
javax.servlet.ServletOutputStream ou = response.getOutputStream();
//文件名
String filename=new String(request.getParameter("filename").getBytes("ISO8859_1"),"utf-8").toString();
//路径
String filepath=ServletActionContext.getServletContext().getRealPath("/upload/"+filename);
//Syst
阅读全文
摘要:SSH下载的方法name =new String(getFilename().getBytes("iso-8859-1"),"utf-8");
tname=java.net.URLEncoder.encode(name,"utf-8");
String path=ServletActionContext.getServletContext().getRealPath("/upload/"+name);
File file=new File(path); inputStream=new FileInputStream(file);
阅读全文
摘要:document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法.
function subSomething() {
if(document.readyState == “complete”) //当页面加载状态
//页面加载完成你要处理的事在这里写
}
阅读全文