浏览模式: 标准 | 列表分类:系统工程师

今日所学

1.double转String

     double testValue;

     String current = " " + testValue; //  double +" " 返回 String 

2.数字的格式指定

     import java.text.DecimalFormat;

     double current  = 1.523456;
     DecimalFormat df = new DecimalFormat("0000.000");
     df.format(current);

     被format成0001.523了。

3.applet中

   用awt的ui。

   javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());

    获取当前系统的外观!

4.在applet初始化的时候,获取参数应在最前面。并在全局变量中设定!

5.水平滚动条滚动,相应的值改变。

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e) {
     int i = jScrollBar.getValue();     
     String day = DateChange.getday(i);
     jTextField3.setText(day);

}

设置jTextField3的值改变。在该程序中,i为获取的滚动条拖动的格数。    

Tags: applet

EOS和DB2的连接

原来是需要这样设置的:

几点需要注意的地方:
  1. eos自带驱动,默认的driver的驱动不对,需要将net改成app。
  2. 连接地址不能用127.0.0.1:50000,那样会一直报错。
  3. EOS是我的数据库的名称,直接jdbc:db2:EOS就可以建立连接。

Tags: db2, java, eos, 连接

link安装插件

1、下载安装eclipse:

     可以到官方网站http://www.eclipse.org/downloads/index.php下载eclipse的最新版本,当前为eclipse3.1版,下载好后,将其解压缩(假设到e:\eclipse)。

2、配置eclipse 插件

常用的插件有:lomboz(jsp,j2ee开发),tomcatplugin(tomcat插件),easystruts(struts开发
配置插件有两种方法,一是真接将插件释放到eclipse文件夹,二是写LINK文件,链接,这种方法比较容易管理插件,添加,删除插件都很方便。下面主要说用第二种方法:将所有下载的插件释放到同一文件夹下,假设为e:\eclipse_plugins.以配置tomcatplugin插件为例:将tomcatplugins释放到e:\eclipse_plugins下,然后组织文件夹为:
e:\eclipse_plugins
        |--tomcatPluginV31beta
             |--eclipse
                |-plugins(新建,eclipse会自动检查features和plugins文件夹下的内容)
                    |---com.sysdeo.eclipse.tomcat_3.1.0.beta
按上面示例,建好之后,回到eclipse文件夹,新建一个links目录,在该目录下,新建一个文件tomcat.link(文件名任意),内容为:path=e:/eclipse_plugins/tomcatPluginV31beta
(让eclipse自动检查tomcatpluginV3下的features或plugins文件夹)打开eclipse,即可看到菜单栏上多了tomcat选项。如果不成功,删除configuration下,除config.ini的所有文件夹,重启eclipse即可。
   e:\eclipse
       |--links
         |---tomcat.link(配置其它插件时,新建相应的link文件)

PS:以下,附常用插件下载地址:

Lombo
 http://www.objectlearn.com/

TomcatPlugin
 http://www.sysdeo.com/eclipse/tomcatPlugin.html

EasyStruts
 http://easystruts.sourceforge.net

Properties Editor  编辑java的属性文件,并可以自动存盘为Unicode格式
http://propedit.sourceforge.jp/index_en.html
 
Colorer Take  为上百种类型的文件按语法着色
http://colorer.sourceforge.net/
 
XMLBuddy 编辑xml文件
www.xmlbuddy.com
 
Code Folding  加入多种代码折叠功能(比eclipse自带的更多)
http://www.coffee-bytes.com/servlet/PlatformSupport
 
Easy Explorer  从eclipse中访问选定文件、目录所在的文件夹
http://easystruts.sourceforge.net/

Tags: ecplise 插件

smartupload 在jsp里面

<jsp:userbean id="mySmartUpload" scope="page" class=""/>

try{

mySmartUpload.initalize(pageContext);

mySmartUpload.service(request,response);

mySmartUpload.upload();

String fn=mySmartUpload.getFiles().getFile(0).getFileName();

mySmartUpload.save("upload/");

}catch()

{

}

smartupload的用法

String path = Tools.getClassPath()+"/photo/";
com.jspsmart.upload.SmartUpload  smart=new SmartUpload();
smart.initialize(this.getServletConfig(),request,response);
smart.setMaxFileSize(500000);

User u=(User)request.getSession().getAttribute("user");
if(request.getParameter("submited")!=null)
{
try
{
    //上传
smart.upload();
}
catch(SecurityException e)
{
  if(e.getMessage().indexOf("1105")!=-1||e.getMessage().indexOf("1110")!=-1)
  {
response.getOutputStream().print("<script>alert('请选择小于500K的jpg或jpeg的图片!')</script>");

  }

}
//如果有文件
if(smart.getFiles().getCount()>0)
{
com.jspsmart.upload.File file=smart.getFiles().getFile(0);
if(file.getFileExt().toLowerCase() .equals("jpg")||file.getFileExt().toLowerCase() .equals("jpgeg"))
{
//得到照片路径
//给文件重新命名
path=path+u.getId()+".jpg";
//得到物理路径
java.io.File  f=new java.io.File(path);
//保存
file.saveAs(f.getAbsolutePath());
KnowlegeProxy.setUploadPhoto(u,"1");
out.println("<script>window.self.top.location.reload()</script>");
}
else
{
response.getOutputStream().print("<script>alert('请选择扩展名为jpg或jpeg的图片!')</script>");
}
}
}