Guides

          對(duì)guides這個(gè)詞認(rèn)識(shí)源于struts文檔,參考、指南,這里是sfilyh 關(guān)于CODE的guides。

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            21 隨筆 :: 1 文章 :: 5 評(píng)論 :: 0 Trackbacks

          2011年11月3日 #


          1.配置網(wǎng)絡(luò)參數(shù) /etc/sysconfig/network-scripts/ifcfg-eth0
          請(qǐng)記得,這個(gè) ifcfg-eth0 與文件內(nèi)的 DEVICE 名稱配置需相同,并且,在這個(gè)文件內(nèi)的所有配置, 基本上就是 bash 的變量配置守則啦!
          [root@linux ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
          DEVICE
          =eth0                <== 網(wǎng)絡(luò)卡代號(hào),必須要 ifcfg-eth0 相對(duì)應(yīng)
          BOOTPROTO
          =static           <== 啟動(dòng)協(xié)議,有 dhcp 及 static 這里是 static
          BROADCAST
          =192.168.1.255    <== 就是廣播位址羅
          HWADDR
          =00:40:D0:13:C3:46   <== 就是網(wǎng)絡(luò)卡位址
          IPADDR
          =192.168.1.13        <== 就是 IP 啊
          NETMASK
          =255.255.255.0      <== 就是子遮罩網(wǎng)絡(luò)
          NETWORK
          =192.168.1.0        <== 就是網(wǎng)域啊!該網(wǎng)段的第一個(gè) IP
          GATEWAY
          =192.168.1.2        <== 就是默認(rèn)路由!
          ONBOOT
          =yes                 <== 是否啟動(dòng)啟動(dòng)的意思
          MTU
          =1500                   <== 就是最大傳輸單元的配置值。
          #GATEWAYDEV
          =eth0           <== 主要路由的裝置為那個(gè),通常不用配置
          配置完成后啟動(dòng)網(wǎng)卡,ifup eth0 。此時(shí)可以ping通局域網(wǎng)內(nèi)的計(jì)算機(jī)。

          2.配置 DNS 的 IP: /etc/resolv.conf
          [root@linux ~]# vi /etc/resolv.conf
          nameserver 
          168.95.1.1
          nameserver 
          139.175.10.20


          3.配置默認(rèn)路由   /etc/sysconfig/static-routes
          [root@linux sysconfig]# vi /etc/sysconfig/static-routes
          any net 
          0.0.0.0 gw 192.168.1.1


          三步配置下來(lái),內(nèi)網(wǎng)和外網(wǎng)ping 成功!

           《靜態(tài)路由詳細(xì)介紹》
            http://my.oschina.net/qichang/blog/33458

           《鳥哥的 Linux 私房菜筆記》在線版
            http://vbird.dic.ksu.edu.tw/linux_basic/linux_basic.php
          posted @ 2012-02-28 16:46 Guides 閱讀(230) | 評(píng)論 (0)編輯 收藏


          1.查看當(dāng)前系統(tǒng)中的用戶
          select user,host,password from mysql.user

           2.為用戶設(shè)置密碼
          set password for root@localhost=password('在這里填入root密碼');


          3.開戶數(shù)據(jù)庫(kù)遠(yuǎn)程訪問(wèn)功能(下面是授予root用戶訪問(wèn)所有數(shù)據(jù)庫(kù)和表的權(quán)限并且設(shè)置訪問(wèn)密碼為root)
          grant all on *.* to root@'%' identified by 'root';




          posted @ 2012-02-21 17:12 Guides 閱讀(185) | 評(píng)論 (0)編輯 收藏


           1.  Spring3.0中的異常處理配置方法

           2. Spring3MVC 在JSP中使用@ModelAttribute

           3. [學(xué)習(xí)筆記](méi)基于注解的spring3.0.x MVC學(xué)習(xí)筆記

           4. Spring3 MVC 深入研究
          posted @ 2012-02-02 16:51 Guides 閱讀(218) | 評(píng)論 (0)編輯 收藏

          使用apache comments Codec 這個(gè)jar


          代碼如下
              public static void main(String[] args) {        
                  String s 
          = "guides";        
                  System.out.println(DigestUtils.md5Hex(s.getBytes()));
              }



          posted @ 2012-01-05 15:04 Guides 閱讀(301) | 評(píng)論 (0)編輯 收藏

          從struts validator中提取出來(lái)的。這種東西寫起來(lái)麻煩,還是直接拷吧!

          \b(^['_A-Za-z0-9-]+(\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\.[A-Za-z0-9-]+)*((\.[A-Za-z0-9]{2,})|(\.[A-Za-z0-9]{2,}\.[A-Za-z0-9]{2,}))$)\b


          posted @ 2011-12-31 17:52 Guides 閱讀(199) | 評(píng)論 (0)編輯 收藏

          配置的時(shí)候,犯了個(gè)很大的錯(cuò)誤,疏忽了。

          自定義二級(jí)域名的需求
          http://guides.network.com 的請(qǐng)求轉(zhuǎn)至 http://www.network.com/guides 而且域名保持不變

          nginx配置代碼
          server {
                  server_name  *.network.com
          ;        
                  
                  if ( $http_host ~* 
          "^(.*?)\.network\.com$")
                  {
                      set $domain $
          1;              
                  }
                  
                  location / {            
                      proxy_pass   http://network
          ;
                      
                      if ($domain !~* ^www$)
                      {
                          rewrite ^/(.*)    /$domain/$
          1 break;
                      }                         
                      
                      proxy_set_header Host $host:
          80;
                      proxy_set_header X_Forwarded_For $remote_addr;
                      index  index.html index.htm;
                  }

          }

          當(dāng)時(shí)用php測(cè)試,用get方式可以拿到值,用post就是拿不到值。最后發(fā)現(xiàn)把name="id"漏掉了.............................




          更新日志
          2011-12-31 17:48:14
          按照這個(gè)配置會(huì)出現(xiàn)一個(gè)問(wèn)題,在oschina上問(wèn)了下,不好解決。
          http://www.oschina.net/question/208700_35450
          posted @ 2011-12-22 17:01 Guides 閱讀(4741) | 評(píng)論 (2)編輯 收藏


          支付寶接口(java版)里摘下來(lái)的。

          String subject = new String(request.getParameter("subject").getBytes("ISO-8859-1"),"utf-8");
          posted @ 2011-12-20 16:23 Guides 閱讀(213) | 評(píng)論 (0)編輯 收藏

           

          function CopyById(id) {
              
          if (!document.body.createControlRange){
                  
          return//只支持IE哦
              }      
              
          var ctrl = document.body.createControlRange();
              
          var domid=document.getElementById(id);
              domid.contentEditable 
          = true;
              ctrl.addElement(domid);
              ctrl.execCommand('Copy');
              domid.contentEditable 
          = false;
              alert('復(fù)制完成');
          }

           

          posted @ 2011-12-17 11:04 Guides 閱讀(458) | 評(píng)論 (0)編輯 收藏

          在bin/catalina.bat中添加一句代碼

          set JAVA_OPTS=-Xms256m -Xmx512m

          如圖


          設(shè)置后tomcat manage中查看status效果




          posted @ 2011-12-14 17:39 Guides 閱讀(389) | 評(píng)論 (0)編輯 收藏

          參考代碼,直接貼上。

          jQuery("#productForm").validate({
              rules:{
                  // ....
              },
              messages:{
                // ....
              },
              showErrors: 
          function(errorMap, errorList) {
                      
          if(errorList.length > 0){
                      alert(errorList[
          0].message);
                      
          return false;
                      }
              },
              ignore:
          "", // 驗(yàn)證所有元素,包括隱藏input
              onfocusout: 
          false,
              onkeyup: 
          false
          });

          posted @ 2011-12-08 16:54 Guides 閱讀(2026) | 評(píng)論 (1)編輯 收藏

               摘要: 在做身份證驗(yàn)證的時(shí)候,補(bǔ)習(xí)了一下身份證組成規(guī)則。突然想到把這些規(guī)則組成一個(gè)程序。

          先看看下面一段簡(jiǎn)介,人人上看到的 http://blog.renren.com/blog/200883456/730064313,介紹挺全的。

          身份證號(hào)碼的編排規(guī)則
          身份證號(hào)碼中這些數(shù)字是怎樣排列的,每個(gè)數(shù)字表示什么意思呢?下面就讓我們一起來(lái)探索其中的規(guī)律吧!新的身份證號(hào)碼是由18位數(shù)字組成的,它們分別表示:

          (1)前1、2位數(shù)字表示:所在省份的代碼;
          (2)第3、4位數(shù)字表示:所在城市的代碼;
          (3)第5、6位數(shù)字表示:所在區(qū)縣的代碼;
          (4)第7~14位數(shù)字表示:出生年、月、日;
          (5)第15、16位數(shù)字表示:所在地的派出所的代碼;
          (6)第17位數(shù)字表示性別:奇數(shù)表示男性,偶數(shù)表示女性;
          (7)第18位數(shù)字是校檢碼:也有的說(shuō)是個(gè)人信息碼,一般是隨計(jì)算機(jī)的隨機(jī)產(chǎn)生,
          看看下面的格式

            閱讀全文
          posted @ 2011-12-08 15:41 Guides 閱讀(1461) | 評(píng)論 (1)編輯 收藏

               摘要: 項(xiàng)目完成了,打算裝個(gè)bug管理工具。看redmine好評(píng)挺高的就裝它吧!

          系統(tǒng)環(huán)境
          system: server2003
          mysql: Server version: 5.5.16
          redmine 1.2.2
          ruby ruby 1.8.6

          下面的安裝,是在mysql裝好的情況下進(jìn)行的。
            閱讀全文
          posted @ 2011-12-05 15:28 Guides 閱讀(3183) | 評(píng)論 (0)編輯 收藏

          首先需要兩個(gè)工具 srvany.exe 和 instsrv.exe

          使用 instsrv  服務(wù)名稱   srvany.exe絕對(duì)路徑

          修改注冊(cè)表
          Windows Registry Editor Version 5.00 
           
          [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\服務(wù)名稱\Parameters] 
          "Application"="值為你要作為服務(wù)運(yùn)行的程序地址"
          "AppDirectory"="值為你要作為服務(wù)運(yùn)行的程序所在文件夾路徑"
          "AppParameters"="值為你要作為服務(wù)運(yùn)行的程序啟動(dòng)所需要的參數(shù)"

          notepad 安裝成服務(wù)啟動(dòng)示例

          instsrv sample1 C:\Windows\System32\srvany.exe
           
          Windows Registry Editor Version 5.00

          [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sample1\Parameters]
          "Application"="C:\\WINDOWS\\SYSTEM32\\notepad.exe"
          "AppDirectory"="C:\\WINDOWS\\SYSTEM32\\"
          "AppParameters"=""

          關(guān)于instsrv.exe和srvany.exe更詳情的介紹和用法 http://wangye.org/blog/archives/42/

          posted @ 2011-11-24 15:42 Guides 閱讀(344) | 評(píng)論 (0)編輯 收藏

          數(shù)據(jù)庫(kù)事務(wù)必須具備ACID特征,ACID是Atomic(原子性)、Consistency(一致性)、Isolation(隔離性)和Durability(持久性)的英文縮寫。下面解釋這幾個(gè)特性的含義。

          原子性:指整個(gè)數(shù)據(jù)庫(kù)事務(wù)是不可分割的工作單元。只有事務(wù)中所有的操作執(zhí)行成功,才算整個(gè)事務(wù)成功;事務(wù)中任何一個(gè)SQL語(yǔ)句執(zhí)行失敗,那么已經(jīng)執(zhí)行成功的SQL語(yǔ)句必須撤消,數(shù)據(jù)庫(kù)狀態(tài)應(yīng)該退回到執(zhí)行事務(wù)前的狀態(tài)。

           

          一致性:指數(shù)據(jù)庫(kù)事務(wù)不能破壞關(guān)系數(shù)據(jù)的完整性及業(yè)務(wù)邏輯上的一致性,例如對(duì)銀行轉(zhuǎn)賬事務(wù),不管事務(wù)成功還是失敗,應(yīng)該保證事務(wù)結(jié)束后ACCOUNTS表中智多星和小不點(diǎn)的存款總額為2000元。

           

          隔離性:指的是在并發(fā)環(huán)境中,當(dāng)不同的事務(wù)同時(shí)操作相同的數(shù)據(jù)時(shí),每個(gè)事務(wù)都有各自的完整數(shù)據(jù)空間。

           

          持久性:指的是只要事務(wù)成功結(jié)束,它對(duì)數(shù)據(jù)庫(kù)所做的操作就必須永久保存下來(lái)。即使發(fā)生系統(tǒng)崩潰,重新啟動(dòng)數(shù)據(jù)庫(kù)系統(tǒng)后,數(shù)據(jù)庫(kù)還能恢復(fù)到事務(wù)結(jié)束時(shí)的狀態(tài)。事務(wù)ACID特性是由關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng)(RDBMS,在本書中也簡(jiǎn)稱為數(shù)據(jù)庫(kù)系統(tǒng))來(lái)實(shí)現(xiàn)的。


          數(shù)據(jù)庫(kù)管理系統(tǒng)采用日志來(lái)保證事務(wù)的原子性、一致性和持久性。日志記錄了事務(wù)對(duì)數(shù)據(jù)庫(kù)所做的更新,如果某個(gè)事務(wù)在執(zhí)行過(guò)程中發(fā)生錯(cuò)誤,就可以根據(jù)日志,撤銷事務(wù)對(duì)數(shù)據(jù)庫(kù)已做的更新,使數(shù)據(jù)庫(kù)退回到執(zhí)行事務(wù)前的初始狀態(tài)。

          數(shù)據(jù)庫(kù)管理系統(tǒng)采用鎖機(jī)制來(lái)實(shí)現(xiàn)事務(wù)的隔離性。當(dāng)多個(gè)事務(wù)同時(shí)更新數(shù)據(jù)庫(kù)中相同 的數(shù)據(jù)時(shí),只允許持有鎖的事務(wù)更新該數(shù)據(jù),其他事務(wù)必須等待,直到前一個(gè)事務(wù)釋放了鎖,其他事務(wù)才有機(jī)會(huì)更新該數(shù)據(jù)。

           

           

          posted @ 2011-11-21 23:48 Guides 閱讀(198) | 評(píng)論 (0)編輯 收藏

          網(wǎng)上看到在spring里配置sessionFactory的另一種寫法。

          我一直用的配法

             <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
                  
          <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
                  <property name="url" value="jdbc:mysql://192.168.1.111:3306/comment_new"/>
                  
          <property name="password" value="root" />
                  
          <property name="username" value="root" />
              
          </bean>
              
              
          <bean id="sessionFactory"
                  class
          ="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                  
          <property name="dataSource" ref="dataSource" />
                  
          <property name="mappingDirectoryLocations">
                      
          <list>
                          
          <value>classpath:com/cocosily/comment/po</value>
                      
          </list>
                  
          </property>

                  
          <property name="hibernateProperties">
                      
          <props>
                          
          <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                          
          <prop key="hibernate.show_sql">true</prop>
                          
          <prop key="hibernate.format_sql">true</prop>
                          
          <prop key="hibernate.cache.use_query_cache">true</prop>
                          
          <prop key="hibernate.cache.use_second_level_cache">true</prop>
                      
          </props>
                  
          </property>
              
          </bean>

          見(jiàn)到別人的另一種配法,直接保留hibernate.cfg.xml配置文件。然后通過(guò)屬性引入一下

          <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
              
          <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
              
          <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
          </bean>


          posted @ 2011-11-19 11:16 Guides 閱讀(2093) | 評(píng)論 (0)編輯 收藏


          在oschina看到一道問(wèn)答題,一看題一點(diǎn)思路也沒(méi)有。忍不住看了答案,對(duì)連接查詢又重新認(rèn)識(shí)了一下。

          題目:有一張數(shù)據(jù)表的主鍵ID,是自增的,但有時(shí)候存在一些重復(fù)記錄,清除重復(fù)記錄之后,就出現(xiàn)了ID不連續(xù)的情況(如下圖),現(xiàn)要新增一條記錄,其ID要為最小的中斷值(下圖的最小中斷值2),請(qǐng)寫出最簡(jiǎn)單的SQL語(yǔ)句?

          ID

          name

          1

           

          3

           

          4

           

          5

           

          6

           


          答案很精簡(jiǎn)
          select min(a.id)+1 from test a left join test b on a.id=b.id-1 where b.id is null;

          "test" 
          is your table name:)

          還有一些其它的解決方法http://www.oschina.net/question/111204_32051





          posted @ 2011-11-19 10:19 Guides 閱讀(419) | 評(píng)論 (0)編輯 收藏

          struts2提供了聲明式異常處理,可以針對(duì)不同的異常做不同的處理。我想攔截Action中的所有異常,然后通過(guò)Log4j進(jìn)行日志記錄,再呈現(xiàn)到頁(yè)面。

          首先在struts配置文件中配上一個(gè)全局的java.lang.Exception。這樣所有異常都會(huì)被這個(gè)exception-mapping所攔截,并返回一個(gè)name為ALL_EXCEPTION的result

                  <global-exception-mappings>
                      <exception-mapping result="ALL_EXCEPTION" exception="java.lang.Exception"/>
                  </global-exception-mappings>

          再來(lái)配置一個(gè)<global-results>來(lái)處理異常,通過(guò)chain跳轉(zhuǎn)到exectionHandle這個(gè)action中

                  <global-results>       
                      <result name="ALL_EXCEPTION" type="chain">exectionHandle</result>
                  </global-results>

          exectionHandle配置,這里的action用spring來(lái)管理的(exectionHandleAction)。處理異常后返回到指定界面(界面用的veloctiy模板)。

                  <action name="exectionHandle" class="exectionHandleAction">
                      <result type="velocity">/WEB-INF/public_ucenter_shopmanage/ServerExceptionPage.html</result>            
                  </action>

          最后看一下action中的處理,直接用logo4j輸出。

          public class ExceptionHandleAction extends ActionSupport{
              private static final long serialVersionUID = 6019598646317953160L;
              private static Logger logger = Logger.getLogger(ExceptionHandleAction.class);
              
              @Override
              public String execute() throws Exception {
                  String logoInfo = ActionContext.getContext().getValueStack().findString("exceptionStack");
                  logger.info(logoInfo);
                  logger.debug(logoInfo);
                  return SUCCESS;
              }    
          }
          posted @ 2011-11-16 16:48 Guides 閱讀(215) | 評(píng)論 (0)編輯 收藏

          chain、dispatcher(默認(rèn))、freemarker、httpheader、redirect、redirectAction、stream、velocity、xslt、plainText
          posted @ 2011-11-15 18:07 Guides 閱讀(169) | 評(píng)論 (0)編輯 收藏

          Eclipse中的一些特殊的注釋技術(shù)包括:
              1.    // TODO —— 表示尚未完成的待辦事項(xiàng)。
              2.    // XXX —— 表示被注釋的代碼雖然實(shí)現(xiàn)了功能,但是實(shí)現(xiàn)方案有待商榷,希望將來(lái)能改進(jìn)。
              3.    // FIXME —— 表示被注釋的代碼需要被修正。

              4.自定義標(biāo)簽 
              window-->preferences-->java-->compiler-->Task tags 

          上述所有注釋都會(huì)被eclipse task視圖所收集。在項(xiàng)目發(fā)布前,檢查一下task視圖是一個(gè)很好的習(xí)慣

          posted @ 2011-11-14 15:54 Guides 閱讀(4415) | 評(píng)論 (1)編輯 收藏

          Struts
          1.Struts2 Action的單元測(cè)試
             使用Junit進(jìn)行測(cè)試struts的action
             http://blog.csdn.net/theoffspring/article/details/6314196



          posted @ 2011-11-03 18:16 Guides 閱讀(110) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 新郑市| 阳城县| 都安| 平定县| 桃园县| 吉安市| 蓬安县| 邻水| 富平县| 宜君县| 松潘县| 广元市| 蓬安县| 陆丰市| 通山县| 上犹县| 鸡泽县| 社会| 合川市| 武鸣县| 赣州市| 吉木乃县| 乌兰县| 荔浦县| 兴城市| 泸定县| 金坛市| 济宁市| 三穗县| 禄劝| 伊金霍洛旗| 平顺县| 北票市| 溧水县| 虹口区| 临汾市| 拜泉县| 容城县| 肇州县| 本溪| 宽甸|