锘??xml version="1.0" encoding="utf-8" standalone="yes"?>日韩视频―中文字幕,91精品国产色综合久久不卡蜜臀,国产精品亚洲成人http://www.aygfsteel.com/sunnyiric/zh-cnSun, 22 Jun 2025 12:15:25 GMTSun, 22 Jun 2025 12:15:25 GMT60TOMCAT 涓殑璁塊棶鎺у埗絳栫暐http://www.aygfsteel.com/sunnyiric/archive/2008/12/26/248503.htmlsunnyiricsunnyiricFri, 26 Dec 2008 09:17:00 GMThttp://www.aygfsteel.com/sunnyiric/archive/2008/12/26/248503.htmlhttp://www.aygfsteel.com/sunnyiric/comments/248503.htmlhttp://www.aygfsteel.com/sunnyiric/archive/2008/12/26/248503.html#Feedback0http://www.aygfsteel.com/sunnyiric/comments/commentRss/248503.htmlhttp://www.aygfsteel.com/sunnyiric/services/trackbacks/248503.htmlTOMCAT 涓殑璁塊棶鎺у埗絳栫暐

TOMCAT鐨勫畨鍏ㄦ帶鍒剁瓥鐣ユ槸鏍規(guī)嵁Servlet 2.4瑙勮寖鏉ュ疄鐜扮殑銆?

1.鍦?CATALINA/conf/server.xml鏂囦歡涓厤緗?

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"  debug="0" resourceName="UserDatabase"/>

榪欓噷UserDatabase鏄竴涓猨ndi鐨勫悕縐幫紝涔熼渶瑕佸湪server.xml涓厤緗紝瀵瑰簲浜?CATALINA/conf/tomcat-users.xml鏂囦歡

2.tomcat-users.xml鏂囦歡閲岄潰瀹氫箟浜嗙敤鎴峰拰瑙掕壊

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="manager" password="tomcat" roles="manager"/>
  <user username="admin" password="tomcat" roles="admin"/>
</tomcat-users>

3.鍦ㄧ浉搴旂殑搴旂敤鐨剋eb.xml鏂囦歡涓姞鍏?lt;security-constraint><login-config> <security-role>鏍囩錛屽涓嬫墍紺猴細(xì)
  <!-- Security is active on entire directory -->
  <security-constraint>
    <display-name>Tomcat Server Configuration Security Constraint</display-name>
    <web-resource-collection>
      <web-resource-name>Protected Area</web-resource-name>
      <!-- Define the context-relative URL(s) to be protected -->
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <!-- Anyone with one of the listed roles may access this area -->
      <role-name>admin</role-name>
    </auth-constraint>
  </security-constraint>

  <!-- Login configuration uses form-based authentication -->
  <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>Tomcat Server Configuration Form-Based Authentication Area</realm-name>
    <form-login-config>
      <form-login-page>/login.jsp</form-login-page>
      <form-error-page>/error.jsp</form-error-page>
    </form-login-config>
  </login-config>

  <!-- Security roles referenced by this web application -->
  <security-role>
    <description>
      The role that is required to log in to the Administration Application
    </description>
    <role-name>admin</role-name>
  </security-role>

4.鍦?<login-config>鏍囩鐨?lt;auth-method>FORM</auth-method>灞炴т腑錛屽彲浠ョ湅鍒拌繖閲岀殑authentication method 璁劇疆涓篎ORM錛岃繖鏄竴縐嶅熀浜庤〃鍗曠殑鐢ㄦ埛璁よ瘉鏂瑰紡銆傚熀浜巉orm鐨勭敤鎴瘋璇侀渶瑕佸湪<form-login-page>/login.jsp</form-login-page>瀹氫箟鐨勭櫥闄嗛〉闈腑鎻愪緵涓涓寘鎷敤鎴峰悕鍜屽瘑鐮佺殑html琛ㄥ崟錛岃繖涓〃鍗曠浉瀵瑰簲浜庣敤鎴峰悕鍜屽瘑鐮佺殑鍏冪礌蹇呴』鏄痡_username鍜宩_password,騫朵笖琛ㄥ崟鐨凙CTION蹇呴』涓簀_security_check銆傝濡傦細(xì) 
<form method="POST" action="j_security_chack"> 
<input type="text" name="j_username"> 
<input type="password" name="j_password"> 
</form> 

鍦ㄩ獙璇侀氳繃涔嬪悗錛宭ogin欏甸潰浼?xì)鑷姩铦{鍚戣搴旂敤鐨勯粯璁ら〉闈?index.html,index.jsp絳夌瓑)銆?

闄や簡FORM楠岃瘉鏂瑰紡涔嬪錛岃繕鏈塀ASIC鍜孋LIENT-CERT榪欎袱縐嶇敤鎴瘋璇佹柟寮忥紝鍓嶈呮槸鍩烘湰鐨勭敤鎴瘋璇佹柟寮忥紝瑕佹眰嫻忚鍣ㄥ脊鍑轟竴涓璇濇錛屽綍鍏ョ敤鎴峰悕鍜屽瘑鐮併傚悗鑰呮槸浣跨敤瀹㈡埛鏁板瓧璇佷功鏉ヨ璇佽姹傘?br />

5.浠ヤ笂鍥涙瀹屾垚涔嬪悗渚垮彲浠ラ氳繃鍦╰omcat-users.xml鏂囦歡涓坊鍔犵敤鎴峰拰瑙掕壊鏉ュ疄鐜拌闂帶鍒朵簡銆傝繕鏄瘮杈冩柟闈㈢殑銆?/p>



sunnyiric 2008-12-26 17:17 鍙戣〃璇勮
]]>
hibernate 涓婚敭鐢熸垚絳栫暐http://www.aygfsteel.com/sunnyiric/archive/2008/12/22/247783.htmlsunnyiricsunnyiricMon, 22 Dec 2008 08:29:00 GMThttp://www.aygfsteel.com/sunnyiric/archive/2008/12/22/247783.htmlhttp://www.aygfsteel.com/sunnyiric/comments/247783.htmlhttp://www.aygfsteel.com/sunnyiric/archive/2008/12/22/247783.html#Feedback0http://www.aygfsteel.com/sunnyiric/comments/commentRss/247783.htmlhttp://www.aygfsteel.com/sunnyiric/services/trackbacks/247783.htmlHibernate鐨勪富閿敓鎴愮瓥鐣ユ湁濂藉嚑縐嶏細(xì)
1) assigned
2) hilo
3) seqhilo
4) increment
5) identity
6) sequence
7) native
8) uuid.hex
9) uuid.string
10) foreign
涓鑸岃█錛屽埄鐢╱uid.hex鏂瑰紡鐢熸垚涓婚敭灝嗘彁渚涙渶濂界殑鎬ц兘鍜屾暟鎹簱騫沖彴閫?br /> 搴旀с傚彟澶栫敱浜庡父鐢ㄧ殑鏁版嵁搴擄紝濡侽racle銆丏B2銆丼QLServer銆丮ySql 絳夛紝閮芥彁
渚涗簡鏄撶敤鐨勪富閿敓鎴愭満鍒訛紙Auto-Increase 瀛楁鎴栬匰equence錛夈傛垜浠彲浠ュ湪鏁?br /> 鎹簱鎻愪緵鐨勪富閿敓鎴愭満鍒朵笂錛岄噰鐢╣enerator-class=native鐨勪富閿敓鎴愭柟寮忋?br /> 涓嶈繃鍊煎緱娉ㄦ剰鐨勬槸錛屼竴浜涙暟鎹簱鎻愪緵鐨勪富閿敓鎴愭満鍒跺湪鏁堢巼涓婃湭蹇呮渶浣籌紝
澶ч噺騫跺彂insert鏁版嵁鏃跺彲鑳戒細(xì)寮曡搗琛ㄤ箣闂寸殑浜掗攣銆?br /> 鏁版嵁搴撴彁渚涚殑涓婚敭鐢熸垚鏈哄埗錛屽線寰鏄氳繃鍦ㄤ竴涓唴閮ㄨ〃涓繚瀛樺綋鍓嶄富閿姸
鎬侊紙濡傚浜庤嚜澧炲瀷涓婚敭鑰岃█錛屾鍐呴儴琛ㄤ腑灝辯淮鎶ょ潃褰撳墠鐨勬渶澶у煎拰閫掑閲忥級錛?br /> 涔嬪悗姣忔鎻掑叆鏁版嵁浼?xì)璇诲彇杩欎釜鏈澶у鹼紝鐒跺悗鍔犱笂閫掑閲忎綔涓烘柊璁板綍鐨勪富閿紝涔?br /> 鍚庡啀鎶婅繖涓柊鐨勬渶澶у兼洿鏂板洖鍐呴儴琛ㄤ腑錛岃繖鏍鳳紝涓嬈nsert鎿嶄綔鍙兘瀵艱嚧鏁版嵁
搴撳唴閮ㄥ嬈¤〃璇誨啓鎿嶄綔錛屽悓鏃朵即闅忕殑榪樻湁鏁版嵁鐨勫姞閿佽В閿佹搷浣滐紝榪欏鎬ц兘浜х敓
浜嗚緝澶у獎鍝嶃?br /> 鍥犳錛屽浜庡茍鍙慖nsert瑕佹眰杈冮珮鐨勭郴緇燂紝鎺ㄨ崘閲囩敤uuid.hex 浣滀負(fù)涓婚敭鐢熸垚
鏈哄埗銆?br /> 鍙﹀鎴戜滑鍙互鎵╁睍Hibernate鐨勭被鏉ュ仛鑷繁鐨勪富閿敓鎴愮瓥鐣ワ細(xì)
java 浠g爜
 
  1. package com.gsta.eshore.framework.util.uid;  
  2. import java.io.Serializable;  
  3. import org.hibernate.engine.SessionImplementor;  
  4. import org.hibernate.id.AbstractUUIDGenerator;  
  5. import org.hibernate.id.Configurable;  
  6. import org.hibernate.id.IdentifierGenerator;  
  7. import java.util.Properties;  
  8. import org.hibernate.Hibernate;  
  9. import org.hibernate.dialect.Dialect;  
  10. import org.hibernate.type.Type;  
  11. import org.hibernate.util.PropertiesHelper;  
  12. /** 
  13.  * <b>uuid</b><br> 
  14. * @author hwq 
  15.  */  
  16. public class UIDGenerator extends AbstractUUIDGenerator implements Configurable {  
  17.     private static long lastTime = System.currentTimeMillis();  
  18.     private static short lastCount = -32768;  
  19.     private static Object mutex = new Object();  
  20.     private static long ONE_SECOND = 1000L;  
  21.     private String sep = "";  
  22.     public Serializable generate(SessionImplementor session, Object obj) {  
  23.         long l = 0L;  
  24.         short word0 = 0;  
  25.         int i = 0;  
  26.         synchronized(mutex)  
  27.         {  
  28.             if(lastCount == 32767)  
  29.             {  
  30.                 for(boolean flag = false; !flag;)  
  31.                 {  
  32.                     l = System.currentTimeMillis();  
  33.                     if(l < lastTime + ONE_SECOND)  
  34.                     {  
  35.                         try  
  36.                         {  
  37.                             Thread.currentThread();  
  38.                             Thread.sleep(ONE_SECOND);  
  39.                         }  
  40.                         catch(InterruptedException interruptedexception) { }  
  41.                     } else  
  42.                     {  
  43.                         lastTime = l;  
  44.                         lastCount = -32768;  
  45.                         flag = true;  
  46.                     }  
  47.                 }  
  48.             } else  
  49.             {  
  50.                 l = lastTime;  
  51.             }  
  52.             word0 = lastCount++;  
  53.             i = getHostUniqueNum();  
  54.         }  
  55.         String s = Integer.toString(i, 16) + sep + Long.toString(l, 16) + sep + Integer.toString(word0, 16);  
  56.         if(s.length() > 24)  
  57.             s = s.substring(s.length() - 24);  
  58.         return s;  
  59.     }  
  60.     public Serializable generate_old(SessionImplementor session, Object obj) {  
  61.         String name = obj.getClass().getName();  
  62.         return new StringBuffer(64)  
  63.             .append(name.substring(name.lastIndexOf('.')+1)).append(sep)  
  64.             .append((short)getIP()).append(sep)  
  65.             .append(Math.abs((short)getJVM())).append(sep)  
  66.             .append(getCount())   
  67.             .toString();  
  68.     }  
  69.     private static int getHostUniqueNum()  
  70.     {  
  71.         return (new Object()).hashCode();  
  72.     }  
  73.     public void configure(Type type, Properties params, Dialect d) {  
  74.         sep = PropertiesHelper.getString("separator", params, "");  
  75.     }  
  76.     public static void main( String[] args ) throws Exception {  
  77.         Properties props = new Properties();  
  78.         props.setProperty("separator""");  
  79.         IdentifierGenerator gen = new UIDGenerator();  
  80.         ( (Configurable) gen ).configure(Hibernate.STRING, props, null);  
  81.         IdentifierGenerator gen2 = new UIDGenerator();  
  82.         ( (Configurable) gen2 ).configure(Hibernate.STRING, props, null);  
  83.         for ( int i=0; i<10; i++) {  
  84.             String id = (String) gen.generate(null, gen);  
  85.             System.out.println(id);  
  86.             String id2 = (String) gen2.generate(null, gen2);  
  87.             System.out.println(id2);  
  88.         }  
  89.     }  
  90. }  
榪欎釜綾誨繀欏昏鎵╁睍AbstractUUIDGenerator騫跺疄鐜癈onfigurable鎺ュ彛錛屽湪generate鏂規(guī)硶涓敓鎴愭垜浠兂瑕佺殑涓婚敭銆?br /> 鍦╤ibernate鐨勯厤緗枃浠朵腑瑕佸仛浠ヤ笅鐨勯厤緗?
xml 浠g爜
 
  1. <id name="id" type="java.lang.String">  
  2.       <column name="id" length="24" />  
  3.       <generator class="com.gsta.eshore.framework.util.uid.UIDGenerator"><param name="separator">-</param></generator>  
  4.   </id>  
Generator鐨勭被瑕佸紩鐢║IDGenerator錛屽茍涓斿彲浠ュ甫鍙傛暟鐢熸垚涓婚敭錛岀ず渚嬫槸鏍規(guī)嵁鏃墮棿錛孖p絳夌敓鎴愪竴涓?4浣嶇殑瀛楃涓層傝繖鏍峰仛鐨勭伒媧繪уぇ澶ф彁楂樹簡錛屾彁渚涗簡鏈濂界殑鎬ц兘鍜屾暟鎹簱騫沖彴閫傚簲鎬с?br /> 浣嗘槸鏈夋椂鍊欐垜浠湪淇濆瓨涓鏉¤褰曠殑鏃跺欐槸涓嶈兘鎸囧畾涓婚敭鐨勶紝鍥犱負(fù)瀹冪殑涓婚敭瑕佹潵婧愪簬鍏朵粬鐨勮〃鐨勪富閿紝錛坔ibernate鎺ㄨ崘鐢ㄤ唬鐞嗕富閿紝浣嗘槸鏈夋椂鍊欒璁$殑鏃跺欐病鏈夌敤鍒幫級銆傝繖涓椂鍊欑殑涓婚敭鐢熸垚絳栫暐灝辮鏄痑ssigned浜嗐備負(fù)浜嗕繚鎸佷富閿殑榪炶瘡鎬э紝鎴戞諱笉鑳藉張鐢ㄥ彟澶栦竴縐嶄富閿敓鎴愮瓥鐣ュ惂銆?br /> 浠跨収涓婇潰鐨勭被錛屾垜浠仛涓涓敓鎴?4涓洪殢鏈哄瓧絎︿覆鐨勭被銆?br />
java 浠g爜
 
  1. package com.gsta.eshore.framework.util.uid;  
  2. public class UID  
  3. {  
  4.     private static long lastTime = System.currentTimeMillis();  
  5.     private static short lastCount = -32768;  
  6.     private static Object mutex = new Object();  
  7.     private static long ONE_SECOND = 1000L;  
  8.     public UID()  
  9.     {  
  10.     }  
  11.     public static String getUID()  
  12.     {  
  13.         long l = 0L;  
  14.         short word0 = 0;  
  15.         int i = 0;  
  16.         synchronized(mutex)  
  17.         {  
  18.             if(lastCount == 32767)  
  19.             {  
  20.                 for(boolean flag = false; !flag;)  
  21.                 {  
  22.                     l = System.currentTimeMillis();  
  23.                     if(l < lastTime + ONE_SECOND)  
  24.                     {  
  25.                         try  
  26.                         {  
  27.                             Thread.currentThread();  
  28.                             Thread.sleep(ONE_SECOND);  
  29.                         }  
  30.                         catch(InterruptedException interruptedexception) { }  
  31.                     } else  
  32.                     {  
  33.                         lastTime = l;  
  34.                         lastCount = -32768;  
  35.                         flag = true;  
  36.                     }  
  37.                 }  
  38.             } else  
  39.             {  
  40.                 l = lastTime;  
  41.             }  
  42.             word0 = lastCount++;  
  43.             i = getHostUniqueNum();  
  44.         }  
  45.         String s = Integer.toString(i, 16) + "`" + Long.toString(l, 16) + "`" + Integer.toString(word0, 16);  
  46.         if(s.length() > 24)  
  47.             s = s.substring(s.length() - 24);  
  48.         return s;  
  49.     }  
  50.     private static int getHostUniqueNum()  
  51.     {  
  52.         return (new Object()).hashCode();  
  53.     }  
  54.   
  55.    public static void main(String[] args) {  
  56.         for (int i = 0; i < 100; i++) {  
  57.             String uid=getUID();  
  58.             System.out.println(uid);  
  59.         }  
  60.         }  
  61. }  
鍦╯ave涓涓疄浣撶殑鏃跺欒皟鐢╡ntity.setId(UID.getUID())銆?br /> 鍛靛懙錛屼互鍚庣敤hibernate灝變笉鐢ㄧ儲鐢ㄤ粈涔堜富閿敓鎴愮瓥鐣ヤ簡錛岃嚜宸卞仛涓涓?br />

sunnyiric 2008-12-22 16:29 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 靖边县| 兴义市| 临沂市| 三河市| 牟定县| 郑州市| 五家渠市| 峨眉山市| 青冈县| 南城县| 左贡县| 前郭尔| 尉氏县| 秭归县| 仲巴县| 贺兰县| 伊金霍洛旗| 通许县| 萝北县| 徐闻县| 六安市| 清丰县| 静安区| 松桃| 丹凤县| 射洪县| 浦城县| 西和县| 高要市| 柏乡县| 襄樊市| 丹寨县| 通化县| 治县。| 囊谦县| 榆社县| 临海市| 新蔡县| 康乐县| 大厂| 三河市|