posts - 18,  comments - 1,  trackbacks - 0
           

          1)最近做上傳文件時遇到了討厭的亂碼問題!
          現象是上傳純文本文件,顯示沒有問題,但是word文檔中有圖表就會出現亂碼!

          原因,是由于我用了clob字段來保存文檔!

          2)在下載時遇到中文文件名亂碼.解決方法是把文件名重新編碼!
          ?response.setHeader("Content-disposition", "attachment;filename=\"" +new String(bszn.getFileFileName().getBytes("gb2312"),"iso8859-1")+"\"");

          mysql?的blob字段只有64k,要有大點的文件要用longBlob
          ??????????????????

          posted @ 2007-01-30 23:12 sunny 閱讀(213) | 評論 (0)編輯 收藏
          #include<iostream>//快速排序不新建臨時數組
          using namespace std;
          void swap(int &a,int &b){
          ??? if(&a==&b)
          ???????? return;???
          ???? a=a^b;
          ???? b=a^b;
          ???? a=a^b;
          ???? }
          void quick(int *a,int n)
          {
          ???? if(n<=1)
          ???????? return ;
          ???? swap(*a,a[n>>1]);
          ???? int*lp=a+1;
          ???? int*rp=a+n-1;
          ???? while(rp-lp>=0)
          ???? {
          ????? if(*lp>*a)
          ??????????? {
          ???????????? if(*rp<*a){?????????????
          ?????????????? swap(*lp++,*rp--);
          ?????????????? }
          ???????????? else
          ?????????????? --rp;
          ??????????? }
          ????? else
          ???????? ++lp;???????????
          ????? }
          ? swap(*a,*rp);???
          ?????????????
          ??? int left=rp-a;
          ??? quick(a,left);
          ??? quick(a+left+1,n-left-1) ;??
          ?}
          int main(){
          ??? int a[5]={0 ,5, 9, 8, 7 };
          ??? int b[10]={2,5,9,6,3,1,4,7,1 ,5 };
          ??? quick(b,10);
          ??? for(int i=0;i<10;i++)
          ??????????? cout<<b[i]<<' ';
          ??????????? cout<<endl;
          ??? char ch;
          ??? cin>>ch;
          ??? return 0;
          ??? }
          posted @ 2007-01-25 22:51 sunny 閱讀(244) | 評論 (0)編輯 收藏

          #include<iostream>//一個快速排序的例子

          using? namespace std;

          void swap(int &a,int &b){
          ???? a=a^b;
          ???? b=a^b;
          ???? a=a^b;
          ???? }

          void quick(int *a,int n){
          ???? if(n<=1)
          ???? return;
          ???? swap(*a,a[n>1]);//把中間的數作為分組的標準,并把它換到數組首
          ???? int *p=new int[n];
          ???? int*lp=p;
          ???? int*rp=p+n-1;
          ???? int*pt=a+1;
          ???? int pivot=*a;
          ???? for(int i=1;i<n;i++)//把數據 考到臨時數組
          ???????????? {
          ????????????? if(*pt>pivot)
          ??????????????????? *rp--=*pt++;
          ?????????????? else
          ??????????????????? *lp++=*pt++;??????????????????
          ???????????? }
          ?? *lp=pivot;
          ??? pt=a;
          ??? lp=p;
          ??? for(int i=0;i<n;i++)//把數據考回來
          ?????????? *pt++=*lp++;
          ? delete[] p;
          ? int left=rp-p;//計算左邊部分的元素個數
          ? quick(a,left);
          ?quick(a+left+1,n-left-1);?
          }

          ?

          int main(){
          ??
          ??? int a[11]={5,456,3219,416,4,64,31,987,1987,98731,9841};
          ?quick(a,11);
          ?
          ?for(int i=0;i<11;i++)
          ???????? cout<<a[i]<<' ';
          ???????? cout<<endl;
          ???????? char t;
          ???????? cin>>t;
          ???????? return 0;
          ??????
          ??????
          ??? }

          posted @ 2007-01-24 22:16 sunny 閱讀(877) | 評論 (0)編輯 收藏


          #include<iostream>
          using namespace std;
          typedef int T;

          class Node{
          ????? T data;
          ????? Node *next;
          public:
          ?????? Node(T t):data(t),next(NULL){}
          ?????? friend class List;?????
          ?????? };
          ?????
          class List{
          ????? Node * head;
          ????? int len;
          public:
          ??????? List(int len=0):len(len),head(NULL){}
          ??????? ~List(){clear();}
          ??????? Node* & getp( int pos ); 
          ??????? void insert( T d, int pos=0 );//插入
          ??????? int size();
          ??????? bool empty();
          ?????? ?void travel();//遍歷
          ????????void clear();
          ??????? int find( T d );//查找
          ??????? bool update( T d1, T d2 );//更新
          ??????? bool erase( T d );//刪除
          ??????? T getHead();
          ??????? T getTail();
          ??????? void reverse();
          ????? };
          void List::insert(T d,int pos){
          ???? Node *p=new Node(d);
          ???? Node *&pn=getp(pos);
          ???? p->next=pn;
          ???? pn=p;
          ???? ++len;
          ???? }
          ????
          Node*& List::getp(int pos){//返回一個引用而不是一個復制的數據
          ???? if(pos<0||pos>len)
          ??????????? pos=len;??????????????????
          ???? if(pos==0)
          ???????????? return head;
          ?????? Node*p=head;?????
          ???? for(int i=0;i<pos-1;i++)
          ??????????? p=p->next;
          ???? return p->next;
          ???? }
          int List::size(){
          ??? return len;
          ??? }
          bool List::empty(){
          ???? return head==NULL;
          ???? }?
          ??????
          void List::clear(){
          ????? while(head!=NULL){
          ???? Node *p =head->next;
          ???? delete head;
          ???? head=p;
          ???? }??
          ???? len=0 ;???????????????
          ???? }
          void List::travel(){
          ???? Node*p=head;
          ???? while(p!=NULL){
          ???? cout<<p->data<<' ';
          ???? p=p->next;??????????????
          ???? }
          ???? cout<<endl;??
          ???? }
          int List::find( T d ){
          ???? Node*p=head;
          ???? int pos=0;
          ????
          ???? while(p!=NULL){
          ??????? if(d==p->data)
          ??????????? return pos;
          ??????? p=p->next;
          ??????? ++pos;???????????????
          ???? }????
          ?????????? return -1;
          ???? }
          bool List::update( T d1, T d2 ){
          ???? int t=find(d1);
          ???? if(t==-1)
          ?????? return false;
          ???? Node*&p=getp(t);
          ???? p->data=d2;
          ???? return true;
          ???? }
          bool List:: erase(T d){
          ???? int t=find(d);
          ???? if(t==-1)
          ?????? return false;
          ????? Node*&pn=getp(t);
          ????? Node*p=pn;
          ????? pn=pn->next;
          ????? delete p;
          ????? --len;?????
          ???? return true;
          ???? }
          ?void List:: reverse(){
          ????? Node *ph=head;
          ????? Node *p=NULL;
          ????? head=NULL;
          ????? while(ph!=NULL){
          ??????? p=ph;
          ??????? ph=ph->next;
          ???????
          ??????? p->next=head;
          ??????? head=p;
          ???? }
          ????
          ????? }
          ?????
          T List::getHead(){
          ????? if(empty())
          ????????? return T();??????????
          ??????? return head->data;?????????
          ????? }
          T? List::getTail(){
          ????? if(empty())
          ?????????? return T();
          ?????? return getp(len-1)->data;????????????
          ????? }
          int main(){
          ??? List obj;
          ?obj.reverse();
          ?obj.travel();
          ?obj.insert(1,-1);
          ?obj.insert(2,-1);
          ?obj.insert(3,-1);
          ?obj.insert(4,-1);
          ?obj.insert(5);
          ?obj.insert(6);
          ?obj.insert(7);
          ?obj.insert(8);
          ?obj.insert(60,6);
          ?obj.insert(40,4);
          ?obj.insert(20,2);
          ?obj.travel();
          ?obj.reverse();
          ?obj.travel();
          ??? cout<<obj.find(60)<<endl;
          ?obj.update(20,600);
          ?obj.travel();
          ?obj.erase(600);
          ?obj.travel();
          ?cout<<obj.getHead()<<' '<<obj.getTail()<<endl;
          ?int t;
          ?cin>>t;
          ?return 0;
          ??? }

          posted @ 2007-01-23 21:59 sunny 閱讀(181) | 評論 (0)編輯 收藏

          import jxl.Workbook;
          import jxl.Sheet;

          import java.io.*;
          import java.nio.Buffer;

          /**
          ?* Created by IntelliJ IDEA.
          ?* User: sunny
          ?* Date: 2006-9-27
          ?* Time: 15:25:39
          ?* To change this template use File | Settings | File Templates.
          ?*/
          public class a {


          ??? public static void main(String args[]) {
          ??????? StringBuffer buffer = new StringBuffer();
          ??????? try {
          ??????????? FileWriter out = new FileWriter("C:\\Documents and Settings\\sunny\\桌面\\kd.txt");
          ??????????? Workbook workbook = Workbook.getWorkbook(new File("C:\\Documents and Settings\\sunny\\桌面\\kd.xls"));
          ??????????? Sheet sheet = workbook.getSheet("kd");
          ??????????? int r = sheet.getRows();
          ??????????? int c = sheet.getColumns();
          ??????????? buffer.append("numleng=").append(r).append("&");
          ??????????? for (int i = 0; i < r; i++) {
          ??????????????? for (int j = 0; j < c; j++) {
          ??????????????????? buffer = buffer.append("n").append(i).append("=").append(sheet.getCell(j, i).getContents()).append("&");
          ??????????????????? //?? System.out.print(sheet.getCell(j, i).getContents());
          ??????????????? }
          ??????????? }
          ?????????? out.write(buffer.toString());
          ??????????? workbook.close();
          ??????? } catch (Exception e) {
          ??????????? System.out.println(e);
          ??????? }
          ??????? {
          ??????? }
          ??? }
          }

          posted @ 2006-09-27 17:51 sunny 閱讀(141) | 評論 (0)編輯 收藏
          終于搞出來了把它寫下來備份一下!我用的是apache_2.0.59-win32-x86-no_ssl(1).msi 和 resin3.0.18

          先把resin3.0.18 下的mod_caucho.dll考到apache的modules下再把下面一段考到httpd.conf的后面就ok了

          LoadModule caucho_module modules/mod_caucho.dll
          ResinConfigServer localhost 6802
          CauchoStatus yes
          ?<LocationMatch "/WEB-INF/">
          ? AllowOverride None
          ? deny from all
          ?</LocationMatch>
          ?<LocationMatch "/META-INF/">
          ? AllowOverride None
          ? deny from all
          ?</LocationMatch>?
          ?<IfModule mod_caucho.c>
          ResinConfigServer localhost 6802
          <Location /caucho-status>
          SetHandler caucho-status
          </Location>
          </IfModule>
          AddHandler caucho-request .action? .jsp
          <Location /servlet/*>
          SetHandler caucho-request
          </Location>

          這跟apache 的版本有關如果在2.2apache就會報錯!
          posted @ 2006-09-06 17:23 sunny 閱讀(195) | 評論 (0)編輯 收藏
          ???前幾天在寫代碼的時又遇到一個頁面不能顯示一個list的錯誤!
          ???現象:后臺可以打出log(list.size())。但是頁面上用c 標簽顯示時,提示類型錯誤。用ww標簽可以輸出? 循?環,但是具體的property顯示不出來!
          原因:原來是在用Hibernate 的createMysqlQuery()時沒有加上addEntity().也就是hibernate 返回的是一個object 的list。而我在頁面上是把這個list ,當作具體的對象的list操作的!所以才出現了這樣的錯誤!
          啟發:在與數據庫打交道時要注意把object轉換成具體的class!要盡量用hibernate的hql,這樣可以減少類型轉換問題。要盡量用面向對象的思想來考慮問題!
          posted @ 2006-07-19 17:37 sunny 閱讀(117) | 評論 (0)編輯 收藏

          div.compadmin2 {
          ??????????? top: 172px;
          ??????????? left: 316px;
          ??????????? position: absolute;
          ??????????? border-bottom: #939395 solid 0px;
          ??????????? border-left: #939395 solid 0px;
          ??????????? border-right: #939395 solid 0px;
          ??????????? border-top: #939395 solid 0px;
          ??????????? width: 541px;
          ??????????? height: 466px;
          ??????????? padding: 5px;
          ??????????? overflow: auto;

          ??????? }

          posted @ 2006-07-14 11:07 sunny 閱讀(139) | 評論 (0)編輯 收藏
          僅列出標題
          共2頁: 上一頁 1 2 
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          相冊

          收藏夾

          朋友

          搜索

          •  

          最新評論

          評論排行榜

          主站蜘蛛池模板: 富川| 东丰县| 宁海县| 洛川县| 长兴县| 北安市| 马尔康县| 安乡县| 西昌市| 台州市| 石家庄市| 定陶县| 巫溪县| 鹤庆县| 新和县| 河西区| 平山县| 恭城| 马公市| 崇文区| 江川县| 洛川县| 桂阳县| 青阳县| 包头市| 长阳| 天门市| 平顺县| 珠海市| 调兵山市| 华池县| 龙井市| 靖边县| 深州市| 长汀县| 远安县| 云安县| 石嘴山市| 东辽县| 诸暨市| 明光市|