2016年7月5日

财务制度题库

     摘要: 1财务制度题库 单选题 1.下列各会计要素,(   )不是反映财务状况的会计要素。 A.资产          B.负债          C.收入    ...  阅读全文

posted @ 2021-10-22 23:09 youngturk| 编辑 收藏

jquery 向mybitis后台传完整时间

var ssshsj = new Date( $("#ssshsj").val().replace(/-/g,"/")); 对于Ibatis操作Date/Time/DateTime,总结如下: 将pojo的属性类型设置为java.sql.Date(或java.sql.Time, java.sql.Timestamp),此时会严格遵循这三种类型的语义。但此方法因存在前文中提到的性能问题,在JDK1.6以前的JDK版本中能少使用就少使用。 如果你想在pojo中使用java.util.Date, 则要注意: 完整的日期时间,要确保jdbcType为空,或为DATE,TIME以外的值 只需要时间,要指定jdbcType=”TIME” 只需要日期,要指定jdbcType=”DATE”

posted @ 2017-03-26 00:22 youngturk| 编辑 收藏

webwork 实现数据生成text文件,并进行压缩,并进行下载

//实现压缩文件功能,采用commons-io-2.0.1.jar ,commons-compress-1.5.jar插件
        final OutputStream out = new FileOutputStream("D:/EDI/EDi.zip");  //实例文件输出流
        ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, out);  
        //实例化存档输出流,工厂方法创建zip的存档输出流
//        File f1 = new File(file.getPath());
        os.putArchiveEntry(new ZipArchiveEntry(file.getName()));  //生成存档文件名
        IOUtils.copy(new FileInputStream(file), os);  //添加拷贝存档文件
        
        os.closeArchiveEntry();  
        os.close();  
        
        //*************************
        try {
            File input = new File("D:/EDI/EDi.zip");//获得下载文件路径
            contentType="application/octet-stream";
            docStream = new FileInputStream(input);//获得输入流名称
            contentDisposition =URLEncoder.encode(input.getName() ,"UTF-8");
           } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
           }  
           return "download";
WEBWORK的文件下载机制。使用起来还是比较简单的。
下面是用法说明:
首先在一个ACTION中,如果判断有权限进行文件下载。
则:
1、读出该下载文件,并生成一个流。 文件名应当从请求的request中读出,或从用户的表中取出。
public String downLoadFile(String fileName){
   try {
    File input = new File("e:/engilish literature.doc");
    docStream = new FileInputStream(input);
    contentDisposition = "test.txt";
   } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }  
   return "download";
}
2、将输出导向到一个特殊的RESULT中去。叫做Steam Result。
         <action name="register" class="com.job2easy.web.user.RegisterAction">
             <result name="success" type="dispatcher">
                 <param name="location">/home/register-result.jsp</param>
             </result>
             <result name="input">
                 <param name="location">/home/register.jsp</param>
             </result>
             <result name="download" type="stream">
                 <param name="contentType">application/x-msdownload</param>
                 <param name="inputName">docStream</param>
                 <param name="bufferSize">1024</param>              
                 <param name="contentDisposition">attachment;filename="${contentDisposition}"</param>
             </result>

             <interceptor-ref name="params"/>
         </action>
3、这中间有几个参数需要配置:
     contentType设成 application/x-msdownload 就可以。这样浏览器会保证弹出一个下载文件的对话框。
    inputName 这个比较重要,这个名字是输入流的名称, 以后要steam result的实现类中为根据OGNL的表达式去查找的。
    contentDisposition 这个是下载之后,保存在用户端的文件名称。${contentDisposition} 看一下代码。如果写成上述的方式,就有机会在ACTION中设置文件名。
4、另外一个参数:contentLength就是下载文件的大小,webwork的stream result似乎实现有问题,不能根据文件的大小动态进行设置,只能写死。
     这个参数的意义是告诉浏览下载的文件有多大,以便浏览器正确的显示进度条。如果这个功能很重要的话,可以重新写一个RESULT来实现。
0

posted @ 2016-08-09 17:49 youngturk 阅读(255) | 评论 (0)编辑 收藏

经典

http://blog.csdn.net/jackfrued/article/details/44921941

posted @ 2016-08-08 15:07 youngturk 阅读(165) | 评论 (0)编辑 收藏

sql行列互转

数据列出来如下:
 ID NAME    COUR SCORE
--- ------- ---- -----
  1 name_1  语文    33
  1 name_1  数学    63
  1 name_1  英语    71
  1 name_1  历史    68
  1 name_1  化学    94
  2 name_2  语文    85
  2 name_2  数学     4
  2 name_2  英语    98
  2 name_2  历史     9
  2 name_2  化学    12
  3 name_3  语文    49
  3 name_3  数学    96
  3 name_3  英语    30
  3 name_3  历史    60
  3 name_3  化学     2
要实现的行转列的效果如下(或者类似的结果):
 ID NAME    SCORES
--- ------- --------------------
  1 name_1  33,63,71,94,68
  2 name_2  85,4,98,12,9
  3 name_3  49,2,60,96,30
通过case表达式
select id,name,sum(case when course='语文' then score end) "语文",
sum(case when course='数学' then score end) "数学",
sum(case when course='英语' then score end) "英语",
sum(case when course='历史' then score end) "历史",
sum(case when course='化学' then score end) "化学"
from HANG2LIE
group by id,name;

union有去重功能:
结构如下:
 ID NAME       Chinese       Math    English    History  Chemistry
--- ------- ---------- ---------- ---------- ---------- ----------
  2 name_2          85          4         98          9         12
  1 name_1          33         63         71         68         94
  3 name_3          49         96         30         60          2
我们要实现如下的查询效果:列转行
 ID NAME     COUR SCORE
--- -------- ---- -----
  2 name_2   语文    85
  1 name_1   语文    33
  3 name_3   语文    49
  2 name_2   数学     4
  1 name_1   数学    63
  3 name_3   数学    96
  2 name_2   英语    98
  1 name_1   英语    71
  3 name_3   英语    30
  2 name_2   历史     9
  1 name_1   历史    68
  3 name_3   历史    60
  2 name_2   化学    12
  1 name_1   化学    94
  3 name_3   化学     2
1、集合查询
实现的SQL语句:
select id,name,'语文' course,chinese score from lie2hang
union
select id,name,'数学' course,math score from lie2hang
union
select id,name,'英语' course,english score from lie2hang
union
select id,name,'历史' course,history score from lie2hang
union
select id,name,'化学' course,chemistry score from lie2hang;

posted @ 2016-08-04 17:51 youngturk 阅读(184) | 评论 (0)编辑 收藏

oracle 分页 伪列 只能小于 不能大于

select * from (select A.*, rownum rn from T_CD_LOC A where rownum > 20) where rn <41 错


select * from (select t.* ,rownum rn from T_CD_LOC t where rownum<=40) where rn>=20 对
firstIndex=0
pageNumber
pageSize=20
select * from (select A.*,rownum rn from T_CD_LOC a where rownum < ((firstIndex+pageNumber+1)*pageSize) where rn >((firstIndex+pageNumber)*pageSize)

posted @ 2016-08-04 08:53 youngturk 阅读(200) | 评论 (0)编辑 收藏

js怎么刷新都不管用

js被缓存了,加控制版本 <script src="../lib_js/paymentplan.js?v=1"></script> 

posted @ 2016-07-13 15:36 youngturk 阅读(193) | 评论 (0)编辑 收藏

Ehcache学习 转2

     摘要: EhCache 分布式缓存/缓存集群开发环境:System:WindowsJavaEE Server:tomcat5.0.2.8、tomcat6JavaSDK: jdk6+IDE:eclipse、MyEclipse 6.6 开发依赖库:JDK6、 JavaEE5、ehcache-core-2.5.2.jarEmail:hoojo_@126.comBlog:http://blog.csdn...  阅读全文

posted @ 2016-07-10 17:14 youngturk 阅读(193) | 评论 (0)编辑 收藏

java 虚拟机监控

3、JConsole监控

     JMX(Java Management Extensions)是一个为应用程序植入管理功能的框架。JMX是一套标准的代理和服务,实际上,用户可以在任何Java应用程序中使用这些代理和服务实现管理。可以利用JDK的JConsole来访问Tomcat JMX接口实施监控,具体步骤如下:

1)首先,打开Tomcat5的bin目录中的catalina.bat文件,添加:

JAVA_OPTS="-Xms512m -Xmx512m -Xmn256m  -XX:PermSize=64m -XX:MaxPermSize=64m  -Djava.rmi.server.hostname=192.168.222.132 -Dcom.sun.management.jmxremote.port=1090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

-Dcom.sun.management.jmxremote:代表开启JMX的管理功能

2)重启tomcat,并查看监控端口(上面配置的1090)是否已启动

3)打开jdk的bin目录(如C:\Program Files\Java\jdk1.7.0_17\bin)下的JConsole,并输入iP和监控端口进行连接

     

 

监控结果:

     

posted @ 2016-07-09 16:06 youngturk 阅读(162) | 评论 (0)编辑 收藏

hibernate 删除关联表

http://www.itzhai.com/hibernate-one-to-many-association-mapping-configuration-and-the-cascade-delete-problem.html首先举一个简单的一对多双向关联的配置:

一的一端:QuestionType类

package com.exam.entity;
import java.util.Set;
public class QuestionType {
    private String typeName;
    private char typeUniqueness;
    private Set quesion;
    public String getTypeName() {
        return typeName;
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
    public char getTypeUniqueness() {
        return typeUniqueness;
    }
    public void setTypeUniqueness(char typeUniqueness) {
        this.typeUniqueness = typeUniqueness;
    }
    public Set getQuesion() {
        return quesion;
    }
    public void setQuesion(Set quesion) {
        this.quesion = quesion;
    }
}

配置文件:

<hibernate-mapping package="com.exam.entity">
    <class name="QuestionType" table="exam_question_type">
        <id name="typeName" column="type_name"></id>
        <property name="typeUniqueness"  column="type_uniqueness"/>
        <set name="quesion" inverse="true" cascade="delete">
            <key column="question_type_name"/>
            <one-to-many class="Question"/>
        </set>
    </class>
</hibernate-mapping>

多的一端:Question类

package com.exam.entity;
import java.util.Date;
public class Question {
    private int questionNo;
    private QuestionType questionType;
    private String questionsTitle;
    public int getQuestionNo() {
        return questionNo;
    }
    public void setQuestionNo(int questionNo) {
        this.questionNo = questionNo;
    }
    public QuestionType getQuestionType() {
        return questionType;
    }
    public void setQuestionType(QuestionType questionType) {
        this.questionType = questionType;
    }
    public String getQuestionsTitle() {
        return questionsTitle;
    }
    public void setQuestionsTitle(String questionsTitle) {
        this.questionsTitle = questionsTitle;
    }
}

配置文件:

<hibernate-mapping package="com.exam.entity">
    <class name="Question" table="exam_question">
        <id name="questionNo" column="question_no" >
            <generator class="increment" />
        </id>
        <many-to-one name="questionType" column="question_type_name"/>
        <property name="questionsTitle" column="questions_title" length="200" />    
    </class>
</hibernate-mapping>

首先说明一下一些常用的属性:

<many-to-one>元素包含以下属性:

name:设定映射的持久化类的属性名
column:设定和持久化类的属性对应的表的外键
class:设定持久化类的属性的类型
cascade:设定是否级联
lazy:设定是否延迟加载

<set>元素包含以下属性:

name:设定映射的持久化类的属性名
cascade:设置是否级联
inverse:设定反向控制,如果为true则一的一端不维护外键
<key>:设定与所关联的持久化类对应的表的外键。
one-to-many:设定所关联的持久化类

如果要对一对多关联映射进行级联删除,可以按照上面的举例进行配置:

首先看到一的一端:

<set name="quesion" inverse="true" cascade="delete">
    <key column="question_type_name"/>
    <one-to-many class="Question"/>
</set>

这里设置inverse表示一的一端不维护外键,设置cascade=”delete”表示删除一的一端时对关联到得多的所有的对象也一起删除

再看到多的一端:

<many-to-one name="questionType" column="question_type_name"/>

这里的column表示外键的名,需要和一的一端设置的key标签里的column保持一致,表示维护同一个键值。

可以按照如下的代码执行删除操作:

session.beginTransaction();

QuestionType questionType = (QuestionType) session.load(QuestionType.class, "判断题");            
session.delete(questionType);        
session.getTransaction().commit();

这里使用load查上来的对象是持久状态的(Persistent),只有是Persistent状态的对象才可以使用session.delete()操作进行级联删除,由new创建的对象属于Transient状态,不能进行session.delete()操作。

posted @ 2016-07-09 14:21 youngturk 阅读(288) | 评论 (0)编辑 收藏

hibernate 删除关联表

需要先删子表,再删除主表,否则报错 好文章 http://www.itzhai.com/hibernate-one-to-many-association-mapping-configuration-and-the-cascade-delete-problem.html

posted @ 2016-07-09 14:18 youngturk 阅读(195) | 评论 (0)编辑 收藏

middlegen生成pojo

http://blog.csdn.net/itcareerist/article/details/5896143

posted @ 2016-07-05 14:24 youngturk 阅读(179) | 评论 (0)编辑 收藏

<2016年7月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

公告

this year :
1 jQuery
2 freemarker
3 框架结构
4 口语英语

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

EJB学习

Flex学习

learn English

oracle

spring MVC web service

SQL

Struts

生活保健

解析文件

搜索

最新评论

阅读排行榜

评论排行榜