`
shiwj1010
  • 浏览: 97450 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
function trim(str){ //删除左右两端的空格 return str.replace(/(^\s*)|(\s*$)/g, ""); } function ltrim(str){ //删除左边的空格 return str.replace(/(^\s*)/g,""); } function rtrim(str){ //删除右边的空格 return str.replace(/(\s*$)/g,""); }
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>frame-study</title> </head> <frameset id="aaa" cols="40%,*" framespacing="0" frameborder="yes" border= ...
!important是CSS1就定义的语法,作用是提高指定样式规则的应用优先权。语法格式{ sRule!important },即写在定义的最后面,例如: box{color:red !important;} .colortest { border:20px solid #60A179 !important; border:20px solid #00F; padding: 30px; width : 300px; } 在Mozilla中浏览时候,能够理解!important的优先级,因此显示#60A179的颜色. 在IE中浏览时候,不能够理解!importan ...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; chars ...
特定string to date: String pattern = "yyyyMMdd"; SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date startTime = null; Date endTime = null; try { startTime = sdf.parse("20090420"); endTime = sdf.parse("20090426"); } catch (ParseException ...
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http:/ ...
public class FilterChar { public static String toHtml(String str) { if(str==null) return null; StringBuffer sb = new StringBuffer(); int len = str.length(); for (int i = 0; i < len; i++) { char c = str.charAt(i); ...
假设页面有个checkbox,name="remember",如果勾选了,就建立cookie,支持中文的话,还必须编码和解码操作 // ** 建立cookies String rememberMe = request.getParameter("rememberMe"); log.debug("logincheckServlet current position >> request.getParameter[remeberMe] = "+rememberMe); if("on" ...

典型的单例模式

    博客分类:
  • j2se
public class Singleton{ private static Singleton instance; //私有化构造方法来防止外部通过new 来创建该类的实例 private Singleton (){ } //使用 synchronzied 保证线程安全 public synchronized static Singleton getInstance(){ if(instance==null){ instance= new Sing ...
import java.sql.Connection; import java.sql.SQLException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; import org.apache.log4j.Logger; public class DataBase { static Logger log = Logger.getLogger("blogjava ...
public class TestReplaceString { public static void main(String[] args) { String a = new String("aaa<br>bbb<br>ccc"); System.out.println(a); String b = a.replace("<br>", "\n"); //String b = a.replaceAll("<br>", " ...
使用spring中的jdbcTemplate,一种配置。在一个service层中,有些情况是会同时调用不同的dao,对数据库进行存取操作,而这些操作具有原子性,即其中任何一个dao操作发生异常,整个受事务管理的方法都要rollback. <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001 ...
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class TestIO { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub byte[] b = new b ...
解码而已 import java.io.UnsupportedEncodingException; import java.net.URLDecoder; public class TestEncode { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String urlEncodeUserName = new String("%E5%AD%99%E8%89%BA%E7%8F%8D&q ...
最典型的链接语句,写这里,方便查找 import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Time; public class TestDate { /** * @param args */ public static void main(Stri ...
Global site tag (gtag.js) - Google Analytics