ZK实现上传设置文件编码

upload.zul:
<button id="browse" upload="true" label="browse"/>

后台处理类:
public void onUpload$browse(UploadEvent event){
    //上传之前,设置编码,比如GBK
    //application是ZK GenericAutowireComposer类的封装对象,可以直接使用
    application.getConfiguration().setUploadCharset("GBK");

    Media media = event.getMedia();
    if(media.getFormat()!=null && media.getFormat().equalsIgnoreCase("txt")){
        String lineStr = "";
        Reader r=media.getReaderData();
        BufferedReader br=new BufferedReader(r);
        lineStr=br.readLine();
        //......
    }
}

你可能感兴趣的:(zk)