當想讓系統啟動時就執行的代碼,可以有2中方法實現:
1.讓一個類實現InitializingBean接口,重寫afterPropertiesSet()方法 ,再把這個類交給spring管理,定義為一個bean,這樣就可以了
2.在一個類中自己寫一個方法,此方法是無參數的,把這個類交給spring管理,定義init-method="自己定義的方法名",這樣也可以,這個接觸了對spring的依賴
當系統管理時執行的代碼可以這樣實現:
讓一個類實現DisposableBean接口,重寫 destroy()方法,再把這個類交給spring管理,
Extjs中分頁的使用:
在后臺查詢程序中查詢出的數據集合要放在一個輔助類的對象中輔助類要有2個屬性,一個放數據總數,一個房數據集合,例如:
public class DirectStore {
private int totalRecords;
private final List<?> results;
public DirectStore(final int totalRecord, final List<?> results) {
super();
this.totalRecords = totalRecord;
this.results = results;
}
public List<?> getResults() {
return this.results;
}
public int getTotalRecord() {
return this.totalRecords;
}
public void setTotalRecord(final int totalRecord) {
this.totalRecords = totalRecord;
}
@Override
public String toString() {
return "{'totalRecords':" + this.totalRecords + ",'results'"
+ this.results + "}";
}
}
把查詢出的額數據集合放在對象中
DirectStore store = new DirectStore(recordNumber, list);
在ext的頁面中,需要先定義如下:
var typeStore = new Ext.data.DirectStore({
paramOrder : [ 'start', 'limit' ],
baseParams : {
'start' : 0,
'limit' : 20
},
root : 'results',
totalProperty : 'totalRecords',//和DirectStore對象的totalRecords屬性一樣
idProperty : 'id',
fields : [ 'id', 'name', 'Unit', 'description' ],//集合中存放的對象的屬性
directFn : EamDjn.getDepartment
});
typeStore.load();
再在頁面下面寫:
bbar: new Ext.PagingToolbar({
pageSize: 20,
store : typeStore,
displayInfo: true,
displayMsg: '顯示第 {0} 條到 {1} 條記錄,一共 {2} 條',
emptyMsg: '沒有記錄'
})
這樣就完成分頁了,需要
摘要: <html> <head> <link rel="stylesheet" type="text/css" href="ext-3.3.1\resources\css/ext-all.css" /> &nbs...
閱讀全文
在tomcat的conf文件夾中的server.xml文件中找到<Connector>節點,在節點中寫上URIEncoding="UTF-8",就可以解決整個項目中的get請求的中文亂碼
detachedCriteria.add(Restrictions.eq("user.userId", userId));
Restrictions.eq()是等于,Restrictions.allMap()使用Map,使用key和value進行多個等于的對比
Restrictions.gt()大于,Restrictions.ge()大于等于,Restrictions.lt()小于,
Restrictions.le()小于等于,Restrictions.between()對應sql中的between字句,
Restrictions.like()對應sql的like字句,
Restrictions.in()對應sql的in字句
Restrictions.and()
Restrictions.or()
Restrictions.sqlRestnction(),是對sql限定查詢
1. String s = “中文”;
S = new String(s.getBytes(“ISO8859-1”),”utf-9”);
2. 使用過濾器:
public class CharsetFilter implements Filter{
private String encoding = "UTF-8";
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding(encoding);
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
String encoding = filterConfig.getInitParameter("encoding");
if(encoding != null) {
this.encoding = encoding;
}
}
}
3.request.setCharacterEncoding(“utf-8”);
找到自己的myeclipse安裝目錄,找到文件
myeclipse.ini,改最后三項數據
-Xmx1024m
-XX:MaxPermSize=1024
-XX:ReservedCodeCacheSize=512m,再重做tomcat就好了