2014年3月20日

python singleton

摘要: 使用decorator的方式: 1 def singleton(cls): 2 instance = {} 3 def returnInstance(): 4 if cls not in instance: 5 instance[cls] = cls() 6 return instance[cls] 7 return returnInstance 8 9 @singleton10 class MyClass(object):11 def __init__(self):12 self.x =... 阅读全文

posted @ 2014-03-20 21:28 saobchj 阅读(224) 评论(0) 推荐(0) 编辑

2014年2月22日

django 解决 mysql 数据库输入中文乱码问题

摘要: 使用mysql的时候,一般都需要兼顾中文,因此首先我们会在mysql.cnf中配置了client和server的默认编码,但是在创建数据库的时候我们依然居然自己指定:1 create database test default charset=utf8;View Code 然后再在django中使用如下命令:python manager.py syncdb此时创建的数据库表使用的默认编码就均是utf8了,然后再在网页中数据中文并且新增的时候也不会乱码了 阅读全文

posted @ 2014-02-22 19:47 saobchj 阅读(3709) 评论(0) 推荐(0) 编辑

2013年2月24日

Hibernate分页2

摘要: 这个是在之前的PagingUtil的基础上做了一些改进,只要传入一个select的sql语句,就可以对其进行分页:PagingUtil 1 package Util; 2 3 import java.util.*; 4 5 import model.*; 6 7 import org.hibernate.Query; 8 import org.hibernate.Session; 9 import org.hibernate.SessionFactory; 10 import org.hibernate.cfg.AnnotationConfiguration; 11 ... 阅读全文

posted @ 2013-02-24 15:12 saobchj 阅读(311) 评论(0) 推荐(0) 编辑

2013年1月26日

sql语句执行加减法

摘要: update user set property=property-1 where username='test';update user set property=property+1 where username='test'; 阅读全文

posted @ 2013-01-26 23:12 saobchj 阅读(8691) 评论(0) 推荐(0) 编辑

2013年1月23日

父页面如何在iframe子页面中取id

摘要: $(window.frames["mainframe"].document.getElementById("viewerPlaceHolder")).css({display:"block"}); 阅读全文

posted @ 2013-01-23 22:02 saobchj 阅读(1773) 评论(0) 推荐(0) 编辑

2013年1月19日

struts2文件下载(解决中文文件名问题)

摘要: 1.首先,jsp页面进行下载的那段话需要使用<s:url>标签:1 <a href="<s:url value='filedownload.action'> 2 <s:param name='fileName' >无线网络.ppt</s:param>3 </s:url>">4 下载文件5 </a>2.struts2.xml文件中的配置: 1 <action name="filedownload" class="Action. 阅读全文

posted @ 2013-01-19 15:25 saobchj 阅读(3175) 评论(1) 推荐(0) 编辑

2013年1月17日

struts整合jQuery与ajax

摘要: 首先来一个测试ajax的按钮:<input type="button" value="ajax" id="test" onclick="testajax()">然后为其注册ajax方法:View Code 1 <script type="text/javascript"> 2 3 function testajax() { 4 // var ctx = ${pageContext.request.contextPath}; 5 alert("in"); 阅读全文

posted @ 2013-01-17 23:42 saobchj 阅读(315) 评论(0) 推荐(0) 编辑

2013年1月12日

double类型取精度

摘要: View Code 1 package Util; 2 3 import java.io.File; 4 import java.math.BigDecimal; 5 6 public class NumberUtil { 7 8 /** 9 * 根据精度截断浮点数10 * @param value 需要截断的浮点数11 * @param scale 精度12 * @return13 */14 public static double round(double value,int scale){15 ... 阅读全文

posted @ 2013-01-12 15:31 saobchj 阅读(907) 评论(0) 推荐(0) 编辑

2013年1月10日

No configuration found for the specified action 原因及解决方案

摘要: 引自力云:警告: No configuration found for the specified action: 'login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.引发原因:底层原因本人不是太清楚,但我理解的是,由于请求页面的namespace属性与struts.xml的namespace属性值不一致引起的,这种警告基本上不会影响系统的运行,但对于一个追求完善的人来说,不得不说,这并不是一道好的风景。所以,这里,提 阅读全文

posted @ 2013-01-10 22:58 saobchj 阅读(572) 评论(0) 推荐(0) 编辑

2013年1月7日

html中select的用法

摘要: 话不多说.直接附demo,简单明了:View Code 1 <html> 2 3 <head> 4 5 <script type="text/javascript"> 6 function test(){ 7 var obj = document.getElementById("s"); 8 var index=obj.selectedIndex; 9 var val = obj.options[index].value; 10 var val2 = obj.o... 阅读全文

posted @ 2013-01-07 22:53 saobchj 阅读(352) 评论(0) 推荐(0) 编辑

导航