java开发小结:(2006.10.12-future)

java开发小结:(2006.10.12-future)
================================================
log.debug(StringUtils.repeat("*",80));
log.debug(StringUtils.center(sql,80,"*"));
log.debug(StringUtils.repeat("*",80));

================================================
select j.customerId,j.project,j.uploadFileId from job j
where j.customerId =
(select p.customerId
from projectprice p
where j.customerId=p.customerId and j.project=p.project)
group by j.customerId

SELECT * FROM ftploguser where exists (select count(processId) from ftploguser group by username)>1;
================================================
查看端口

netstat -an
net view
net user
net share

================================================
数据库导出
String path="mysqldump.exe -uuser -ppwd --opt databasename > d:/databack/xx.sql";
java.lang.Runtime.getRuntime().exec("cmd /c "+path);
System.out.println("数据表已导出到文件xx.sql中");

//数据库导入
String path="mysqladmin -uroot -p create databasename";
java.lang.Runtime.getRuntime().exec("cmd /c "+path);
path="mysql databasename < d:/databack/xx.sql";
java.lang.Runtime.getRuntime().exec("cmd /c "+path);
System.out.println("数据表已从文件xx.sql中导入");
================================================

zip安装mysql

mysqld-nt install ***servername***   --defaults-file=****/**my.ini
mysqld-nt install mysql5111  --defaults-file= F:/server/mysql/mysql5111/my.ini
****/bin/mysqld-nt install mysql5014_2 --defaults-file=****/my-large.ini

mysqld-nt remove  ***servername***

show create table job

my.ini添加
basedir=安装路径
datadir=安装路径/data
port=3307

================================================
mysql --user=root mysql
GRANT USAGE ON *.* TO 'dummy'@'localhost';
对List排序
Collections.sort()
================================================
mysql -P3307 -u root -p simatai
mysql -P3307 -u root -p simatai<"" //恢复
mysqldump -P3307 -u root -p simatai>""  //备份
 

================================================
create table app_user
(
id int unsigned not null auto_increment primary key,
firstname varchar(32) not null,
lastname varchar(32) not null
);

ALTER TABLE location MODIFY COLUMN memo TEXT NOT NULL DEFAULT ''

alter table job add projectId varchar(100) not null default '' after project

alter table projectprice add projectId varchar(100) not null default '' after project

alter table uploadfile add type varchar(10) not null default 'file' after project

ALTER TABLE `simatai`.`projectprice` DROP COLUMN `customerID`

drop database simatai

alter table projectprice add index(projectId)

SELECT filename,SUBSTRING(filename,1,2) FROM workfile where SUBSTRING(filename,1,2)="._"
================================================
DROP VIEW IF EXISTS `simatai`.`v_projectfilesprice`;
CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`
SQL SECURITY DEFINER VIEW `v_projectfilesprice` AS select `job`.`projectId` AS `projectId`,
count(0) AS `files`,
`projectprice`.`price` AS `unitPrice`,
(count(0) * `projectprice`.`price`) AS `price`
from (`job` left join `projectprice` on(`job`.`projectId` = `projectprice`.`projectId`))
group by `job`.`projectId`;
================================================

step1 add javascript to jsp
       class_Name.process("value",reply_value);//value 传递到类的值, 
        reply_value反回值的函数名 class_Name类名
 同时加上这些
 <script language="javascript" src="../js/prototype-1.4.0.js"></script>
 <script type='text/javascript' src='/dwr/engine.js'></script>
 <script type='text/javascript' src='/dwr/util.js'></script>
 <script type='text/javascript' src='/dwr/interface/class_Name.js'></script>
 //与上面使用的类名相同
step2 修改web-inf/drw.xml

<!DOCTYPE dwr PUBLIC
        "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
        "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
    <allow>
        <create creator="new" javascript="class_Name">//与上面使用的类名相同
         <param name="class" value="包路径.class_Name" />//与上面使用的类名相同
        </create>
        <convert converter="bean" match="包路径.class_Name"/>//与上面使用的类名相同
    </allow>
</dwr>

step3  建立 包路径.class_Name.java
public class class_Name extends BaseAction {//与上面使用的类名相同
    定义getter and setter 和常用变量

    public class_Name process(value) throws Exception {//jsp 中定义传入的值 value 传递到类的值 类名与上面使用的类名相同

        this.execute();//执行操作

        return this;
    }

    public String execute() throws Exception {    
        return SUCCESS;
    }
}   

step3 jsp中加上
var reply3 = function(data)  //data 是类中返回值为结果
    {
      var id = data.idOfPage;
      $(id).innerHTML = ""; //定义页面显示内容
    }
对java中是List
javascript
可以获得该List长度length
可能遍历来获得实体bean属性
例如可以这么写
for (var i = 0; i < data.list.length; i++) {
  var username = data.list[i].username;
}
示例
//jsp
<script language="javascript" src="../js/prototype-1.4.0.js"></script>
<script type='text/javascript' src='/dwr/engine.js'></script>
<script type='text/javascript' src='/dwr/util.js'></script>
<script type='text/javascript' src='/dwr/interface/DeleteFile.js'></script>
<script type="text/javascript">
var reply2 = function(data)
{
    var id = data.pageID;
    var data = "";
    $(id).innerHTML = data;
}
</script>
<span id="pageID"></span>
onClick="DeleteFile.process('${username}','${path}','pageID',reply2);"
//web-inf/drw.xml
 <allow>
  <create creator="new" javascript="DeleteFile">
         <param name="class" value="fr.simatai.webwork.ftp.DeleteFile" />
        </create>
        <convert converter="bean" match="fr.simatai.webwork.ftp.DeleteFile"/>
 </allow>
//class
public class DeleteFile /*extends BaseAction*/ {//与上面使用的类名相同
    String pageId;

    public String getPageId() {
        return pageId;
    }

    public void setPageId(String pageId) {
        this.pageId = pageId;
    }

    public DeleteFile process(String username,String filepath,String pageId) throws Exception {
        this.setPageId(pageId);
 //...
        return this;
    }
}
================================================
注释快捷ctr+/
insert 第一次粗线条 第二取消粗线条
================================================
map summary:

Map map = new HashMap();
map.put(key,value);

public List functionname (Map map{
         return getSqlMapClientTemplate().queryForList("idname",map);
    }

<select id="getProjectNameList" resultClass="entity">//返回结果  //同上的idname
        SQL语句
         <dynamic prepend="where">
            <isNotEmpty prepend="and" property="key">   //同map中key相同
                ( customerId = #key# and  #key# !='')   //同map中key相同
            </isNotEmpty>
         </dynamic>
</select>


public List listOption(List keyList){
        List list = new Vector();
        String key = "";
        String val = "";
        for(Iterator it = keyList.iterator();it.hasNext();){
            HtmlOption ho = new HtmlOption();
            key = (String)it.next();
            ho.setKey(key);
            ho.setVal(key);
            list.add(ho);
        }
        return list;
}
================================================
更改是否在屏目上显示
log4j.properties
log4j.rootCategory= debug, stdout, R
#log4j.rootCategory= stdout, R
#log4j.rootCategory=debug, R

================================================
1.更新服务器注意数据库连接(上传时同时备份)
/WEB-INF/classes/web.txt
/WEB-INF/classes/fr/simatai/factory/ibatis-Context.xml
================================================

数据删除
http://photo2:8080/admin/utils/deleteSurplusDataProjecprice.action

================================================
修改ROOT密码

Method 1:
在/usr/local/mysql/bin/下:
./mysqladmin -u root password ‘new_password’
一般安装时用此方法设置。

Method 2:
在mysql状态下:
mysql>UPDATE user SET password=PASSWORD('windows') WHERE user='root';
mysql>FLUSH PRIVILEGES;

Method 3:
mysql>SET PASSWORD FOR root=PASSWORD(’new_password’);
================================================


CVS服务器端设置cvsnt
Repository configuration->add
name ->root name为你的CVS工程程名字
root为项目存放位置
about ->启动cvsnt service 和cvsnt lock service

客户端设置 wincvs
管理-》普通-》
认证方式pserver
路径(服务器端设置的工程名)
服务器端window域下的用户名
-》csv-》本地源文件

关于模块的上传
选中项目下的要CVS的目录——》导入模块|项目
关于模块的下载
选中项目-》真写服务器上项目下需要下载到本地的项目名


================================================
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);

快捷键
ctr+N class
ctr+shift+n file
ctr+shift+c review
ctr+shift+/ 注释
alt+enter    add try { } catch (IOException e) {}
alt+insert   add getter and setter

 

================================================
权限控制
1.设置access list//check point 0220 ///
2.menu加上check point  //
3.simatai.xwork.xml中加上
 <interceptor-ref name="arStack"/>
 <param name="accesRightId">4011</param>
 类继承extends BaseFullAction
4.在framework页面中对要隐藏的修改加上
 <#if AR.OK("4012")>
        <td></td>
        </#if>
5.test权限
  SELECT * FROM simatai.people p;
  sa 改成NO
  页面无法看到menu,说明access正确
  access list 中将admin勾上,能看到menu
  进入页面,看不到按钮,说明设置正确
  将sa 改回,admin改回
================================================
List 初始不能给一个null值,否则不能用add方法
一般定义如下:List jobList=new ArrayList();
多看java基础
================================================
  
photoshop快捷键无效的原因:中文输入法的时候快捷键都无法使用

================================================
webwork得到上下文对象
HttpServletRequest request = ServletActionContext.getRequest();

得到bean webwork setting
private static final XXXXXService instance = new XXXXXService();
XXXXXDao dao;
private XXXXXService() {
    dao = (XXXXXDao) XXXXXBeanFactory.getBean("XXXXXDao");
}

得到当前bean
public final class XXXXXBeanFactory {
    static XmlBeanFactory factory = null;
    static {
        Resource is = new
                InputStreamResource(XXXXXBeanFactory.class.getResourceAsStream("XXX-applicationContext.xml"));
        factory = new XmlBeanFactory(is);
    }
    public static Object getBean(String beanName) {
        return factory.getBean(beanName);
    }
}

XXX-applicationContext.xml中IoC
<bean id="XXXXDao" class="....">
......
</bean>
================================================
快捷键
IntelliJ IDEA
ctr+Shift+/ 注释
ctr+/ 注释
================================================
freemarker模板技术
test.tpl
${a}
${b}
${c}
<#list d as dd>
  ${dd}
</#list>
<#list stu as student>
 ${student.age} ${student.name}
</#list>
<#include "test.txt"> 
<#if c < 90>
less than 90
<#else>
more than 90
</#if> 
The average of 3 and 5 is: ${action.avg(3, 5)}
${r"C:/foo/bar"}
test.java

Student stu1 = new Student();
stu1.setAge(11);
stu1.setName("beauty2001");
Student stu2 = new Student();
BeanUtils.copyProperties(stu2, stu1);
log.debug(stu1);
Configuration freemarker_cfg = new Configuration();
freemarker_cfg.setDirectoryForTemplateLoading(new File("F://testpc"));
Template t = freemarker_cfg.getTemplate("test.tpl");
File afile = new File("F://testpc//test.txt");
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(afile)));
SimpleScalar scalar = new SimpleScalar("green mouse");
SimpleNumber scalar1 = new SimpleNumber(90.5);
List sl = new ArrayList();
sl.add(stu1);
sl.add(stu2);
SimpleSequence sq = new SimpleSequence();
sq.add("a");
sq.add("b");
sq.add("c");
SimpleHash sh = new SimpleHash();
sh.put("a", "a");
sh.put("b", scalar);
sh.put("c", scalar1);
sh.put("d", sq);
sh.put("stu", sl);
sh.put("action", new Test());
try {
 t.process(sh, out);
} catch (TemplateException e) {
 e.printStackTrace();
}


<#switch ftpLogUser.status?if_exists>
<#case "download">
 <img src="/icon/download.gif"  alt="only download">
 <#break>
<#case "upload">
 <img src="/icon/upload.gif"  alt="only upload">
 <#break>
<#case "both">
  <img src="/icon/download.gif"  alt="download"><img src="/icon/upload.gif"  alt="upload">
 <#break>
<#default>
 <img src="/icon/empty.gif"  alt="do nothing">
</#switch>
freemarker
<#if var=var1> //var action中的注入的变量 var1常量
<#else>
</#if>
 
 i.g. <#if invoice.status<2 >disabled</#if>

<#list list_var as var>//list_var action中的注入的List变量

</#list>

if tag
<#if invoice.workYear?string="2,006">selected</#if>
<#if invoice.postedon?exists>${invoice.postedon?string("yyyy-MM-dd")}</#if>

single msg
${updateMessage?if_exists}

list tag
<#list customList as customer>
${customer.code}
</#list>
================================================
//得到class的相对路径
URLDecoder.decode(this.getClass().getClassLoader().getResource("../resource/memo/").getPath(), "UTF-8")
================================================
重写toSting可以可以打印我们想要的
public  String toString()   {
 return  ToStringBuilder.reflectionToString( this ,
 ToStringStyle.MULTI_LINE_STYLE);
}
public   boolean  equals(Object o)   {
 return  EqualsBuilder.reflectionEquals( this , o);
}
public   int  hashCode()   {
 return  HashCodeBuilder.reflectionHashCode( this );
}
================================================
ibatis 总结

<delete id="delXXXX">    //delXXXX delete id name
        sql clause                    
        <dynamic prepend="where">
            <isNotEmpty prepend="and" property="XXXXX.XXXX">   //XXXXX.XXXX  entity properties
                (id = #XXXXX.XXXX# and #XXXXX.XXXX# != "")
            </isNotEmpty>
     ....      //reagain isNotEmpty
        </dynamic>
</delete>

  <select id="XXX" resultClass="XXXX">  //delXXXX delete id name
        select * from ftpaccess
        <dynamic prepend="where">
          sql clause                    
        <dynamic prepend="where">
            <isNotEmpty prepend="and" property="XXXXX.XXXX">   //XXXXX.XXXX  entity properties
                (id = #XXXXX.XXXX# and #XXXXX.XXXX# != "")
            </isNotEmpty>
     .... 
        </dynamic>
    </select>
 <insert id="XXX" parameterClass="XXX">
       Sql  clause
       ....
    </insert>
    <update id="XXX" parameterClass="XXX">
        Sql  clause
       ....
    </update>
================================================
httpd.exe -remove
httpd -J-server -Dresource.app.home="XXXXXXXX" -install   //XXXXXXXX  resin安装路径
把Resin web Server加载到系统服务里

httpd.exe -remove
httpd -J-server -Dresource.app.home="F:/server/resin3014" -Xmn100M -Xms500M -Xmx500M  -install
================================================
cvs 配置
cvsnt server:
1.设置登用名名,密码为永不过期
2.配制cvs上传模块 如 /modelname  f:/XXX/XXX/modelname
wincvs client:
全局
1.认证方式 pserver
2.路径 /modelname
3.主机地址 cvsnt domain
cvs
1.home :本机存放项目地址

操作:
上传项目
选中项目名称-->右键-->导入项目/模块
技巧:
选中要上传的modelname
然后会提示你默认的modelname
选择默认即可
下载模块

删除本地目录,然后下载模块 modelname
技巧:选择下载的模块--->检出项目/模块---->
检出到本地文件夹中的路径中会建一个modelname的文件夹
(千万不要包含本目录名,否则在此目录的目录下建一个相同的目录)
================================================

修改服务里的启动路径
HKEY_ LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services

================================================
<select name="job.cropperId">
 <option SELECTED>XXX</option>
 <option >XXX</option>
 ...
</select>
================================================

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.format(new Date());
获得当前时间 new SimpleDateFormat("yyyy-MM-dd").format(new Date())

================================================

文件解析

List originlist = FileUtils.readLines(new File(str), "UTF-8"); //将文件读进一个list
StringUtils.contains(str, "XXXX")   //对str匹配的字段XXXX进行处理,值为一个boolean值
StringUtils.substringBetween(str, firststr, secondstr);//从str取出夹在firststr和secondstr中的string
StringUtils.substringAfterLast(str, XXXX);//从str中最后首次遇到XXXX开始获得余下的string

================================================

定时扫描总结

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/schedulingContext-timer.xml</param-value>
</context-param>

schedulingContext-timer.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
        "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="timer" class="org.springframework.scheduling.timer.TimerFactoryBean">
        <property name="scheduledTimerTasks">
            <list>
                <ref local="XXXXXX" /> //加载扫描XXXXX,名同下
            </list>
        </property>
    </bean>
    <bean id="XXXXXX" class="org.springframework.scheduling.timer.ScheduledTimerTask">
        <property name="delay">
            <value>10000</value>
        </property>
        <property name="period">
            <value>180000</value>
        </property>
        <property name="timerTask">
            <ref bean="bean_name"/> //bean_name名同下加载的bean_name
        </property>

    </bean>
    <bean id="bean_name" class="class_name"></bean>//扫描处理类class_name
</beans>

//类的编写
public class class_name extends TimerTask {
 public void run() {
        //实现任务代码
 }
}

================================================


 FTPClient client = new FTPClient( );
             client.connect( "127.0.0.1" );
             if(client.login( "bddh", "567" )){
                log.debug("bddh login successful!");
             }

================================================
解析成标准时间
mysql datetime java date
Date parsedDate = DateUtils.parseDate(s, new String []{"yyyy/MM/dd", "yyyy.MM.dd HH:mm:ss", "yyyy-MM-dd HH:mm"}

 SimpleDateFormat sdf = new SimpleDateFormat("E ddMMMyy HH:mm:ss",Locale.US);
        try {
           Date d= sdf.parse("Thu 12Apr07 00:14:26");
            log.debug(d);
        } catch (ParseException e) {
            e.printStackTrace();
        }

================================================
去掉字符串前空白
StringUtils.trimToEmpty(""))
取出字符串中的数字
Float.parseFloat("")
================================================

try{
  FileOutputStream fo = new FileOutputStream("T.zip");
  ZipOutputStream zip = new ZipOutputStream(fo);
  ZipEntry zip_entry = new ZipEntry("T.txt");
  zip.putNextEntry(zip_entry);
  DataOutputStream data_output = new DataOutputStream(zip);
  data_output.writeInt(1);
  zip.close();
  System.out.println("OK!!!!!!!");//提示成功
  }catch (Exception e) {
   System.out.println(e);
  }
}

================================================
//javascript
var nowValue=0;
function loading()
{
    document.getElementById('show').innerHTML="moving selected...pass "+nowValue+" second";
 nowValue++;
 setTimeout("loading()",1000);
}
================================================
javascript打开新窗口
function openwin(url,w,h){
    window.open (url, '_blank', 'height='+h+', width='+w+', top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=n o, status=no');
}
================================================
小数点后保留两位
String s=new DecimalFormat("0.00").format(f);
//s=StringUtils.substringAfter(s,".");
================================================
webwork
if-else tag

<ww:if test="true == true">
   <b>if: Success</b>
</ww:if>

<ww:elseIf test="true == true">
   <b>elseIf: Failure</b>
</ww:elseIf>

<ww:else>
   <b>else: Failure</b>
</ww:else>

if-else tag
<ww:iterator value="resultList.iterator" status="index">
<ww:property value="project"/>
<ww:property value="getPeopleName(cropperId)"/>
</ww:iterator>

single bean
<ww:property value="totalCountItem.projects"/>
================================================
String ls_1;
Process process = null;
/* bakdatabase.bat  mysqldump -u root -pwindows simatai>F://test.sql*/
try {
 process = Runtime.getRuntime().exec("F://bakdatabase.bat");
 BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
 while ((ls_1 = bufferedReader.readLine()) != null)
 System.out.println(ls_1);
try {
process.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
}
} catch (IOException e) {
e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
}

欧元 alt+0128
&#8364 ???????

================================================
web.xml
<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/schedulingContext-timer.xml</param-value>
</context-param>
================================================
freemarker 关于模板的技术处理
 Configuration cfg =  new Configuration();//Configuration.getDefaultConfiguration();
           // cfg.setDirectoryForTemplateLoading(new File("d://temp"));   //define by u
            cfg.setClassForTemplateLoading(this.getClass(), "/");   //WEB-INF/classes dir
            Template temp = cfg.getTemplate("test.txt");
            Map map = new HashMap();
            map.put("act", "ffdsgfd");
            File afile = new File("d:/test1.txt");
          //  Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(afile)));
          //  Writer out = new OutputStreamWriter(System.out);
            StringWriter out = new StringWriter();
            temp.process(map, out);
            String s=out.toString();
            log.debug(s);
================================================
//数据库字符编码转化
ALTER TABLE job CONVERT TO CHARACTER SET UTF8
ALTER TABLE projectprice CONVERT TO CHARACTER SET UTF8
ALTER TABLE ftpdomain CONVERT TO CHARACTER SET UTF8
ALTER TABLE ftpuser CONVERT TO CHARACTER SET UTF8
ALTER TABLE ftpaccess CONVERT TO CHARACTER SET UTF8
ALTER TABLE ftpaccess CONVERT TO CHARACTER SET UTF8
ALTER TABLE ftpvirtual CONVERT TO CHARACTER SET UTF8
================================================
向局域网发送消息
net send gaston2 "还有5分钟就下班关闭服务器了"
net send /domain:workgroup "this is a test./tthis is a test."
ALTER TABLE `simatai`.`ftploguser` ADD COLUMN `actionTime` DATETIME DEFAULT NULL AFTER `status`;
================================================
ibatis
通过<![CDATA[……]]>节点,可以避免SQL 中与XML 规范相冲突的字符对
XML 映射文件的合法性造成影响。

一般而言,对于insert 、update 、delete 、select 语句,优先采用parameterClass
和resultClass
<select id="getUsers"
parameterClass="user"
resultMap="get-user-result">

select
id,
name,
sex
from t_user
<dynamic prepend="WHERE">
<isNotEmpty prepend="AND" property="name">
(name like #name#)
</isNotEmpty>
<isNotEmpty prepend="AND" property="address">
(address like #address#)
</isNotEmpty>
</dynamic>
</select>
================================================
< replaced with &lt;
> replaced with &gt;
& replaced with &amp;
" replaced with &quot;
================================================
JS超连接
window.location.href=URL
================================================
己知年份,月份转化为标准日期
Calendar calendar   = Calendar.getInstance();
calendar.set(year,month,day);
Date d=calendar.getTime();
================================================
当前时间为准,取出前三天时间
 Date d = new Date();
        String todaystr = new SimpleDateFormat("yyyy_MM_dd").format(d);
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        cal.add(Calendar.DATE, -1);
        String yesterdaystr = new SimpleDateFormat("yyyy_MM_dd").format(cal.getTime());
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(d);
        cal1.add(Calendar.DATE, -2);
        String thedaybeforeyesterdaystr = new SimpleDateFormat("yyyy_MM_dd").format(cal1.getTime());
================================================
IntelliJ IDEA 6.0.1 修改编码
File->setting->general->properties Files

================================================

更改虚拟内存页面文件的大小
控制面板-->系统-->高级-->性能-->设置-->虚拟内存->更改
如果减小了页面文件设置的初始值或最大值,则必须重新启动计算机才能看到这些改动的效果。增大通常不要求重新启动计算机。

runas /user:computername/Administrator "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl"

 我的电脑->高级->设置->调整为最佳性能

================================================

添加DNS、IIS和DHCP服务 字串8

    1、添加IIS。选“控制面板→添加/删除程序→添加/删除Windows组件→Internet信息服务→全选”。 字串2

    2、添加DHCP和DNS。选“控制面板→添加/删除程序→添加/删除Windows组件→网络服务→选中:动态主机配置协议DHCP→选中:域名服务系统DNS”。

字串2


    3、添加成功后,不需重新启动,即可在“开始→程序→管理工具”中看到并使用相关服务。

================================================
对局域网控制上网
http://192.168.1.1
admin
admin
安全设置-->防火墙设置-->开启防火墙
-->开启MAC地址过滤-->仅允许己设MAC地址表中的己启用的MAC地址防问Internate
MAC地址过滤-->

================================================
earth服务器代理设置
安装FreeProxyClient
ports-->设置代理的端口及类型
users设置登陆的用户
starts/stop 重启freeproxy服务器

客户端
填上主机名 端口 用户名 和密码
================================================
JAVA中利用dos命令操作文件系统
File sourceDir =   new   File("");
File[] fList = sourceDir.listFiles();
File destinationDir =   new   File("");
for(int i=0;i<fList.length;i++){
     String cmd="move /"" +fList[i].getPath()+"/" /"" +destinationDir+"/"";
     log.debug(cmd);
     Runtime.getRuntime().exec("cmd /c" + cmd);
}
================================================
http://www.imagemagick.org/Usage/resize/
ImageMagick 安装与使用
1.  Install ImageMagick 
 q8 contains jmagick.dll compiled against ImageMagick 6.2.9-Q8
 http://www.imagemagick.org/download/binaries/ImageMagick-6.2.9-4-Q8-windows-dll.exe

 q16 contains jmagick.dll compiled against ImageMagick 6.2.9-Q16
 http://www.imagemagick.org/download/binaries/ImageMagick-6.2.9-4-Q16-windows-dll.exe
2.  Copy the jmagick.dll corresponding with the Q8 or Q16 ImageMagick you installed to
    somewhere in your PATH.  I would put it in the same directory as ImageMagick.
3.  Put jmagick.jar in your java classpath.  If you are using Tomcat, or other java
    applications which have their own classloaders, move the jar up to a more global scope.
    If you had placed the jar in WEB-INF/lib and reload the webapp, java will attempt to
    reload jmagick.dll twice, and it will fail.  By moving the jar up, the library will only
    be loaded once per jvm lifetime.  I place mine in %JAVA_HOME%/jre/lib/ext.

查看jmagick.dll是否在 System.getProperty("java.library.path") 
生成缩略图代码测试
public  static void   resize(String   picFrom,String   picTo)   {
 try   {
    //   Resize
    ImageInfo   info   =   new   ImageInfo(picFrom);
    MagickImage   image   =   new   MagickImage(new   ImageInfo(picFrom));
    MagickImage   scaled   =   image.scaleImage(100,   75);//小图片文件的大小.
    scaled.setFileName(picTo);
    scaled.writeImage(info);

 }     catch(MagickApiException ex)   {
    log.debug(ex.getMessage());

 }     catch(MagickException   ex)   {
    log.debug(ex.getMessage());
 }
}
log.debug(System.getProperty("java.library.path"));
System.setProperty("jmagick.systemclassloader", "no");
try {
    ImageInfo info = new ImageInfo(pic);
    MagickImage image = new MagickImage(info);
    //image.setCompression(CompressionType.JPEGCompression);
    //image.setImageFormat("gif");
    //int height= image.getDimension().height;
    MagickImage scaled = image.scaleImage(68,68);//小图片文件的大小.
    scaled.setFileName(picTo);
    scaled.writeImage(info);
} catch (MagickException e) {
    log.debug("creat icon pic fail!"+e);//e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
}
================================================
List 排序
lastStatFileList包含有LastModified属性的实体FileLike
Collections.sort(lastStatFileList, new Comparator() {
    public int compare(Object o1, Object o2) {
 long rs = ((FileLike) o2).getLastModified() - ((FileLike) o1).getLastModified();
 return (new Long(rs)).intValue();
    }
});

================================================
往后推迟多少天计算时间
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -1);
cal.getTime();

================================================
打开新窗口
function openUrlAuto(theUrl,wlength,hlength)
{
    window.open(theUrl, "","width="+wlength+",height="+hlength+",resizable=yes,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,top=150,left=200");
}
================================================
同一行中左右显示数据
<div width=100><div style="float:left;" width=50>dd</div><div style="float:right;" width=50>yyyy</div>  </div>
================================================
控制显示与关闭div
<script type="text/javascript">
    var showsign = null;
    function show_panel(index) {
        if (index == showsign) {
            document.getElementById(index).style.display = "none";
            showsign = null;
            return;
        }
        document.getElementById(index).style.display = "block";
        showsign = index;
    }
</script>
<a style="cursor:hand" οnclick="show_panel('id')" >  X </a>
<div id="id" style="display: none">
================================================
取出一个目录下最近更新的文件
String parentDir =URLDecoder.decode(this.getClass().getClassLoader().getResource("../resource/").getPath(), "UTF-8");
File f=new File(parentDir);
File compareF=null;
if(f.exists()){
 File[] fList = f.listFiles();
 for (int j = 0; j < fList.length; j++) {
  if (fList[j].isFile()) {
      if(compareF==null)compareF=fList[j];
      if(compareF.lastModified()<fList[j].lastModified())compareF=fList[j];
  }
 }
}
================================================
循坏遍历整个文件夹
 public void getDir(String strPath, Date date) {
        //log.debug(strPath);
        File f = new File(strPath);
        if(!f.exists()) {log.debug(strPath+" not exists");return;}
        File[] fList = f.listFiles();
        if(fList.length==0)return;
        for (int j = 0; j < fList.length; j++) {
            File file = fList[j];
            if (file.isFile()) {                         
               //do sth.  
            }
            if (file.isDirectory()) {
                if(FileUtils.sizeOfDirectory(file)>0)   {
   getDir(fList[j].getPath(), date);
                }else{
                      //do sth. 
                }
            }
        }
    }
================================================
xwork标签说明
 name用于区分不同的包,在配置中可以重复
 namespace命令空间规定的请求的路径及返回结果文件存的路径
 extends用于继承以前的命令
================================================
myeclipse 中的编码
eclipse --> window --> Preferences --> General --> Content Types --> Test --> 单击 Java Properties File
,在底部出现 'Default edcodng:',改成utf-8,然后update.
虽然能保存,但还必须利用 native2ascii 来转换一下,不然输出还是乱码.

项目 --> properties->resource->utf-8
================================================
java 调用windows command
安装软件

1.安装ImageMagick-6.2.9-4-Q8-windows-dll.exe
set path=c:/program files/imagemagick-6.2.9q8;
2.安装iview410_setup.exe
set Path=C:/Program Files/IrfanView;
3.安装插件irfanview_plugins_410_setup.exe
4.附助iview410_setup.exe,处理特珠的eps,tif文件
4.解压缩 7z457.exe
set path=C:/Program Files/7-Zip;

//开发中常有的命令
创建目录 mkdir "f:/temp"
创建文件 copy "f:/giga-805-0002.eps"   "f:/615.eps"
解压缩 7z x  -y  "f:/testpc.zip" -o"f:/TODO/temp"
不按比例生成缩略图 convert "f:/629.eps"    -resize 68x68!  "F:/629.gif"
按比例生成缩略图 convert "f:/629.eps"    -resize 68x68  "F:/629.gif"
不按比例生成缩略图 i_view32.exe "f:/635.eps"  /resize=(68,68)    /resample /convert="F:/635.gif"
按比例生成缩略图 i_view32.exe "f:/628.eps"  /resize=(600,600)  /aspectratio  /resample /convert="F:/628.gif"
获得图片大小比例 identify -format "%wx%h"   "f:/627.jpg"
移动目录到目录 move "f:/hidden/rr/*"  "f:/FAIT/rr" 
移动文件到文件 move "f:/hidden/275.jpg"  "f:/FAIT/275.jpg"
删除目录 rd "f:/hidden/rr"
清除目录 rd /Q /s "f:/home/localuser/TODO/temp"
支持命令生成缩略图软件
http://www.irfanview.com
支持库http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_410.zip
解压后放在C:/Program Files/IrfanView/Plugins
命令行形式
http://www.xs4all.nl/~samzen/download/iview/iv_options.txt
http://www.student.oulu.fi/~vtatila/batch_tutorial.html
================================================
java中对命令行的操作

public static boolean exeCommand(String cmd, String msg) {
        boolean result = true;
        log.debug(cmd);
        Process process = null;
        try {
            String[] cmdary = {"cmd", "/C", cmd};
            process = Runtime.getRuntime().exec(cmdary);
            StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "Error");
            StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(), "Output");
            errorGobbler.start();
            outputGobbler.start();
            if (errorGobbler.is.read() != -1) {
                result = false;
            }
            process.waitFor();
        } catch (Exception e) {
            log.debug("execute commond failed : " + e);
            result = false;
        }
        if (!result) {
            log.debug(msg + " failed");
        }
        return result;
}


class StreamGobbler extends Thread {
    Log log = LogFactory.getLog(StreamGobbler.class);
    InputStream is;
    String type;

    StreamGobbler(InputStream is, String type) {
        this.is = is;
        this.type = type;
    }

    public void run() {
        try {
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            while ((line = br.readLine()) != null) {
                if (type.equals("Error"))
                    log.debug(line);
                else
                    log.debug(line);
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}
================================================
java读取目录文件

读取需要的格式到一个collection中
String data[] = {"jpg", "png", "tif", "psd", "gif", "ai", "pdf", "bmp", "eps", "zip", "rar"};
Collection c = FileUtils.listFiles(new File(tempDir), data, true);
对控制最后修改时间和对一些图片格式进行控制的读取到一个collection中
long cutoff = System.currentTimeMillis() - (3 * 60 * 1000);//对3分钟后的文件进行读取
IOFileFilter ageFile = new AgeFileFilter(d.getTime(), false);//d.getTime()为long型 解析最后修改时间为d之后的文件
String[] suffixes = {"jpg", "png", "tif", "psd", "gif", "ai", "pdf", "bmp", "eps", "zip", "rar",""};
IOFileFilter suffixFile = new SuffixFileFilter(suffixes);//对以上后缀进行处理
IOFileFilter fileFilter = FileFilterUtils.andFileFilter(ageFile, suffixFile);
IOFileFilter trueFile = FileFilterUtils.trueFileFilter();   //只对文件处理
// IOFileFilter notDirectory = new NotFileFilter( DirectoryFileFilter.INSTANCE );
Collection uploadFiles = FileUtils.listFiles(dir, fileFilter, trueFile);

================================================
java中md5加密
Common.Md5()
================================================
打印系统属性
for(Iterator it=System.getProperties().keySet().iterator();it.hasNext();){
String key=(String)it.next();
System.out.println(key+" = "+ System.getProperties().get(key));
}
================================================
photoshop 中将javascript加入action
new set->new action->begin recording->file->scripts->browse找到要加的script->stop recording
//要完整的阅读一遍Photoshop CS3 Scripting Guide.pdf(Photoshop Scripting Guide.pdf)
以及相应的js,as,abs
Photoshop 中自动图象操作和控制功能,基本上分几个层次:动作、脚本、Automate、插件、外部程序接口
支持javascript编程插件jseclipse
http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_jseclipse
http://morris-photographics.com/photoshop/scripts/index.html
1.tab   switch不错,可以切换到所有打开的页面  
2.linemover不错,很方便的移动一行  
3.simpleUML很爽的uml工具,用起来很方便 
intelliJ 反编译 IdeaJad
myeclipse 反编译 Jad
IdeaJad   反编译插件。  
Jalopy   in   IDEA可以格式化jsp里的java代码,不过格式化后的代码不够紧凑。  
Rearranger功能更强大的java代码格式化插件,很多设置可以自己配置。
CopyFQNPlugin  
Rearranger  
unitTest  
其实idea的External   Tool   +   Keymap就可以帮你做很多事情了  
workspaces,PE,CopyRight,DashBoard等也不错,一直在用。还有BackGround   Image,可以在Editor中设置背景,放一副山水画,编程时很放松。
================================================
//得到一天的最初的00:00
Calendar cal = Calendar.getInstance();
int   year   =   cal.get(Calendar.YEAR);
int   month   =   cal.get(Calendar.MONTH)+1;
int   day   =   cal.get(Calendar.DATE);
cal.set(year, month, day, 0, 0, 0);  //如果没有解析过,刚从午夜开始的00:00算起
Date date=cal.getTime();

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值