- 浏览: 48545 次
- 性别:
- 来自: 大连
-
最近访客 更多访客>>
最新评论
-
wildeurope:
楼主代码 看起来很乱 不过还是有实用性的 借鉴下
java导出Excel 玩玩吧! -
evanz:
这个只能打word中的文字吧,图片应该是不能打得
java打印word的分享 -
xin163:
不是一般人谁能看懂?
java导出Excel 玩玩吧! -
lerous:
包提供的还不错````至于代码`?````
java导出Excel 玩玩吧! -
jiyuchonger:
很垃圾。。。
java导出Excel 玩玩吧!
java 代码
- package com.axon.fable.empolderpackage.out;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.*;
- /**
- *
@Title: TODO
- *
@Description:
- *
Class: reservation com.axon.fable.util out.java
- *
Date: 2005 2005-5-21 下午09:09:35
- * @Version: 1.0
- * @CopyRight(C) 2007 axon www.axon-dl.com
- * @author hero comeon-liming@163.com
- *
- */
- public class OutJavaScript {
- private static String include="" +
- "<script language=\"javascript\" type=\"text javascript\" src="\"/sams/samspage/js/alert/myalert.js\""></script>";
- /** script language='javascript'>alert('"+outString+"');" +"" +"document.location='"+path+"';
- * 弹出消息进行提示,点击确定按钮执行path
- * @param response
- * @param request
- * @param outString
- * @param path
- */
- public static void outSendNull(HttpServletResponse response,String outString,String path){
- String str="+outString+"');setTimeout(\"document.URL='"+path+"'\",\"2000\");" +
- "" +
- " "+
- ">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /** script language='javascript'>alert("+outString+"');" +"" +"document.location='"+path+"';
- * 弹出消息进行提示,点击确定按钮执行path
- * @param response
- * @param request
- * @param outString
- * @param path
- */
- public static void outSendNull(HttpServletResponse response,HttpServletRequest request,String outString,String path){
- String str="+outString+"\");" +
- "" +
- "setTimeout(\"document.URL='"+path+"'\",\"2000\");" +
- ">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**alert('"+outString+"'); history.back();
- * 弹出消息进行提示,点击确定按钮返回并刷新页面。
- * @param response
- * @param outString
- */
- public static void outString(HttpServletResponse response,String outString,String backNum){
- String str="+outString+"'); setTimeout('history.back("+backNum+");',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**alert('"+outString+"'); history.back();
- * 弹出消息进行提示,点击确定按钮返回并刷新页面。
- * @param response
- * @param outString
- */
- public static void outString(HttpServletResponse response,String outString){
- String str="+outString+"'); setTimeout('history.back();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**alert('"+outString+"'); history.back();
- * 弹出消息进行提示,点击确定按钮关闭父窗体。
- * @param response
- * @param outString
- */
- public static void outCloseReload(HttpServletResponse response,String outString){
- String str="+outString+"'); setTimeout('window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**alert('"+outString+"'); history.back();
- * 弹出消息进行提示,点击确定按钮关闭父窗体。
- * @param response
- * @param outString
- */
- public static void outCloseReload2(HttpServletResponse response,String outString){
- String str="+outString+"'); setTimeout('opener.location.reload();window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**alert('"+outString+"'); history.back();
- * 弹出消息进行提示,点击确定按钮关闭父窗体。
- * @param response
- * @param outString
- */
- public static void outClose(HttpServletResponse response,String outString){
- String str="+outString+"'); setTimeout('window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**alert('"+outString+"'); history.back();
- * 弹出消息进行提示,点击确定按钮关闭父窗体然后执行一个PATH。
- * @param response
- * @param outString
- */
- public static void outClose(HttpServletResponse response,String outString,String goPath){
- String str="+outString+"');setTimeout('opener.location="+goPath+";window.close();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**alert('"+outString+"'); history.back();
- * 弹出消息进行提示,点击确定按钮关闭浏览器。
- * @param response
- * @param outString
- */
- public static void outCloseBrower(HttpServletResponse response,String outString){
- String str="<script language='javascript'>" +
- " var parwin=null;" +
- "var b = \"/sams/login.jsp\";" +
- " if(parent.parent.parent.window!=null)" +
- " parwin=parent.parent.parent.window;" +
- " else if(parent.parent.window!=null)" +
- " parwin=parent.parent.window;" +
- " else if(parent.window!=null)" +
- " parwin=parent.window;" +
- "parwin.opener=null;" +
- "alert(\""+outString+"\");" +
- "window.location=b;" +
- "return;" +
- "</script>";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(str);
- out.flush();
- }
- public static void outCloseBrower(HttpServletResponse response,HttpServletRequest request,String outString){
- PrintWriter out;
- try {
- response.setCharacterEncoding("utf-8");
- out = response.getWriter();
- // out.println(include);
- out.println("<script language='javascript'>alert('"+outString+" ');setTimeout('',2000);</script>");
- out.println("");
- out.println("");
- out.println("<script language=\"javascript\">");
- //out.println("window.opener=null;");
- //out.println("window.close();");
- out.println("var subwin=null;");
- String oper="subwin=open('','','toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,"+
- "center:yes,menubar=no,copyhistory=no,left=0,top=0,resizable=yes,"+
- "width=1024,height=768');";
- out.println(oper);
- out.println("if(subwin!=null)");
- out.println("{");
- // out.println("alert('1');");
- out.println("subwin.document.location='"+request.getContextPath()+"/login.jsp';");
- String str=" var parwin=null; if(parent.parent.parent.window!=null)" +
- " parwin=parent.parent.parent.window;" +
- "else if(parent.parent.window!=null)" +
- "parwin=parent.parent.window; " +
- "else if(parent.window!=null)" +
- "parwin=parent.window;";
- out.println(str+"parwin.opener=null;");
- out.println("parwin.close();");
- out.println("}");
- out.println("else {");
- out.println("window.name='EasyOfficeMain';");
- out.println("document.location='"+request.getContextPath()+"/login.jsp';");
- out.println("}");
- // out.println(op);
- out.println("</script>");
- out.println("");
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- /**alert('"+outString+"'); history.back();window.location.reload();
- * 弹出消息进行提示,点击确定按钮返回并刷新页面。
- * @param response
- * @param outString
- */
- public static void reload(HttpServletResponse response,String outString){
- String str="+outString+"'); setTimeout('history.back();window.location.reload();',2000);\">";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(""+include+str+"");
- out.flush();
- }
- /**if(!window.confirm('"+outString+"')){history.back();}else{" +"" +"document.location='"+path+"'; "+"}
- * 如果点击弹出框的确定按钮,那么招执行path,否则返回.
- * @param response
- * @param request
- * @param outString
- * @param path
- */
- public static void outString(HttpServletResponse response,HttpServletRequest request,String outString,String path){
- String str="";
- str="<script language='javascript'>if(!window.confirm('"+outString+"')){history.back();}else{" +
- "" +
- "document.location='"+path+"'; "+
- "}</script>";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(str);
- out.flush();
- }
- public static void reloadWithMessageShow(HttpServletResponse response,HttpServletRequest request,String message1,String message2,boolean isSuccess){
- String str="<script language='javascript'>";
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- try {
- out = response.getWriter();
- out.println(str);
- out.println("opener.alert("+'"'+""+message1+message2+""+'"'+")");
- out.println("setTimeout('opener.location.reload();',2000); ");
- out.println("window.close();");
- out.println("</script>");
- } catch (IOException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- out.println(str);
- out.flush();
- }
- public static void responseDiv(HttpServletResponse response,HttpServletRequest request,String message1,String message2,boolean isSuccess){
- BufferedReader bufread ;
- String filepath,read;
- try{
- filepath=request.getRealPath("/samspage/js/out/end.txt");
- File file=new File(filepath);
- FileReader fileread= null;
- fileread = new FileReader(file);
- bufread=new BufferedReader(fileread);
- response.setCharacterEncoding("UTF-8");
- PrintWriter out=null;
- out = response.getWriter();
- while((read=bufread.readLine())!=null){
- System.out.println(read);
- out.println(read);
- }
- out.println(" var caption = "+'"'+"短消息提示:"+'"'+";var message = "+'"'+message1+'"'+";var title = "+'"'+message2+'"'+";");
- out.println("window.dialogHeight="+'"'+"150px"+'"'+";window.dialogWidth="+'"'+"280px"+'"'+";window.dialogLeft=screen.width/2-140;window.dialogTop="+'"'+"375px"+'"'+";var w ="+'"'+"50px"+'"'+";var h ="+'"'+"50px"+'"'+";");
- filepath=request.getRealPath("/samspage/js/out/responseHtml.txt");
- file=new File(filepath);
- fileread= null;
- fileread = new FileReader(file);
- bufre
评论
2 楼
comeon-liming
2007-09-08
这只是一个普通的class,我一般在action中调用使用比较频繁,页里中也会调用到.
用这种方式配合样式表与DWR使用效果相当的出色.
用这种方式配合样式表与DWR使用效果相当的出色.
1 楼
duronshi
2007-09-07
你这个类好像运行在servlet情况下的吧?
在传递参数时,将response,request能否设一个默认值,或者判断如果没有对应参数传入时,就不用servelt?
不知个人理解对不?
还有一个小问题,就是css文件里的图片路径不对,应该取掉..之类
在传递参数时,将response,request能否设一个默认值,或者判断如果没有对应参数传入时,就不用servelt?
不知个人理解对不?
还有一个小问题,就是css文件里的图片路径不对,应该取掉..之类
发表评论
-
常用的文件操作方法
2007-12-08 15:22 1456java 代码 import ja ... -
对xml文档操作的常用方法
2007-12-08 15:19 1488java 代码 import ja ... -
操作excel文件,从文件中读取数据。
2007-12-08 15:14 1895java 代码 import or ... -
Subversion之路---实现精细的目录访问权限控制(转载)
2007-11-02 09:34 19771.1 Subversion 权限简介在 ... -
freemarker+velocity+jsf+spring+hibernate 初探一
2007-09-20 19:21 2610喜欢架构方面的东西,在一年多以前就开始接触freem ... -
java导出Excel 玩玩吧!
2007-09-08 13:17 10532java 代码 /* * Gene ... -
java打印word的分享
2007-09-08 13:09 4274大有有兴趣,下来玩玩吧! 有心得多分享哦! -
少走弯路的十条忠告
2007-09-08 12:52 833如何在涉世之初少走弯路,有一个好的开端,开始一番成功的事业? ... -
程序中调用批处理执行Mysql数据库导入导出
2007-09-03 20:39 1938/** * @param cmdStr ... -
hibernate配置
2007-09-03 20:35 818"-//Hibernate/ ... -
struts+hibernate+spring+FreeMarker 2
2007-09-01 21:03 1544自动生成几个文件: 并且,spring的applic ... -
struts+hibernate+spring+FreeMarker
2007-09-01 21:00 930这几天把hibernate和spring好好看了下,再想想st ...
相关推荐
一款基于机器学习的Web日志统计分析与异常检测命令行工具_hy4
基于RBAC权限控制的资产管理系统_hy5
318 Series Hardened Access Points 370 Series Outdoor Access Points 310 Series Campus Access Points IAP-315 IAP-314
最强PMP备考计划、知识整理、试题,并以本系统来展示_hy5
【官方】计算机职业英语一级考试样卷.pdf 【官方】全国机等级考试二级笔试样卷:存取(Access)数据库程序设计.pdf 【官方】全国计算机等级考试二级笔试样卷:C++语言程序设计.pdf 【官方】全国计算机等级考试二级笔试样卷:C语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:德尔菲(Delphi)语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:Java语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:视觉基础语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:视讯FoxPro数据库程序设计.pdf 【官方】全国计算机等级考试三级笔试样卷:PC技术,pdf 【官方】全国计算机等级考试三级笔试样卷:网络技术.pdf 【官方】全国计算机等级考试三级笔试样卷:信息管理技术,pdf 【官方】全国计算机等级考试四级笔试样卷:软件测试工程师.pdf 【官方】全国计算机等级考试四级笔试样卷:数据库工程师,pdf 【官方】全国计算机等级考试四级笔试样卷:数据库技术,pdf 【官方】全国计算机等级考试四级笔试样卷:网络工程师.pdf
SpringBoot网上商城#java#毕业设计#网上商城#springboot#课程设计#编程#thymeleaf_hy4
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
360 Series Outdoor Access Points 303 Series Campus Access Points 303H Series Hospitality Access Points 300 Series Campus Access Points
肽质量指纹图谱提取区域检测系统源码分享[一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]
分布式事务实战_hy4
python网络爬虫按月爬cctv新闻30分的视频_hy4
【golang】企业微信群机器人接口Golang封装
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。
mumu-activemq是一个对老牌mq消息中间件的学习和测试项目,本人通过这个项目来熟悉activemq的消息发送流_hy4
【Python+HTML】基于flask的rbac学生权限管理系统,redis存储session_pgj
一步一步学springboot2:微服务项目实战(第二版)_hy5
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。
新建 DOC 文档.doc
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。