锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲视频自拍,欧美区一区二区三区,成人在线视频成人http://www.aygfsteel.com/leishiran/category/42165.htmlzh-cnWed, 14 Oct 2009 03:24:10 GMTWed, 14 Oct 2009 03:24:10 GMT60絎笁绔?涓簊ervlet鍛藉悕http://www.aygfsteel.com/leishiran/articles/86273.htmlgooglorgooglorFri, 08 Dec 2006 03:41:00 GMThttp://www.aygfsteel.com/leishiran/articles/86273.htmlhttp://www.aygfsteel.com/leishiran/comments/86273.htmlhttp://www.aygfsteel.com/leishiran/articles/86273.html#Feedback0http://www.aygfsteel.com/leishiran/comments/commentRss/86273.htmlhttp://www.aygfsteel.com/leishiran/services/trackbacks/86273.html
娉ㄥ唽servlet/鏄犲皠servlet
 web.xml涓?

<servlet>
    <servlet-name>HelloWorldServlet</servlet-name>   //娉ㄥ唽
    <servlet-class>testservlet.HelloWorldServlet</servlet-class>
</servlet>
</servlet-mapping><servlet-mapping>                  //鏄犲皠
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/helloworld</url-pattern>
</servlet-mapping>
</servlet-mapping><servlet-mapping>                 //澶氫釜鏄犲皠
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/hd</url-pattern>
</servlet-mapping>

鍙互閫氳繃 http://host:port/context path/servlet/registered-servlet-name (璨屼技榪欑娌¤皟璇曞嚭鏉ワ紝姹椼傘傘?
浣跨敤閫氶厤絎?*
<url-pattern>/login/*</url-pattern>  //url鍦板潃鍚庣殑login閮藉皢鐢ㄨ繖涓猻ervlet鏉ヨ姹?
<url-pattern>/*</url-pattern> //鎵浠ラ潪servlet鐨勯〉闈㈠拰鍏朵粬璺緞閮藉皢鐢ㄨ繖涓猻ervlet鏉ヨ姹傦紝濡傛灉鏈夎繖鏍風殑servlet錛屽皢琚紭鍏堛?br /><url-pattern>/servlet/*</url-pattern> //鐢ㄦ潵鍖歸厤 http://host:port/context path/servlet/registered-servlet-name 璁塊棶servlet妯″紡

鐢氳嚦鍙互 <url-pattern>*.jsp</url-pattern> <url-pattern>*.html</url-pattern> 榪欏彨鎵╁睍鏄犲皠
鍦╯ervlet涓漿鍙戣姹?br />protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        PrintWriter out = response.getWriter();
        out.println("Login ...");
        RequestDispatcher dispather = null;
        String param = request.getParameter("go");
        if(param == null ){
            throw new ServletException("Missing parameter!");  //涓嶇煡閬撹繖浜涘紓甯稿湪浣曞鎹曡幏
        }else if(param.equals("h")){
            dispather = request.getRequestDispatcher("/helloworld"); //瀹氫箟灝嗚杞彂浣嶇疆
              //鎴栬?dispather = getServletContext().getNamedDispatcher(“娉ㄥ唽鐨勭被鍚?#8221;);
        }else{
            throw new ServletException("wrong parameter");
        }
        if(dispather != null){
            dispather.forward(request,response);  //榪涜杞彂
        }else{
            throw new ServletException("dispather = null!");
        }
    } 
涓簑eb搴旂敤紼嬪簭鍒涘緩嬈㈣繋鏂囦歡

鍦╳eb.xml涓厤緗?br /><welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>


闄愬埗瀵規煇浜泂ervlet鐨勮姹?br />鏈夋椂鎴戜滑鍙笇鏈涢氳繃璁よ瘉鐨勭敤鎴鋒墠鑳借姹傛煇浜泂ervlet鐨勮瘽錛屽氨鍙互鍦╳eb.xml涓潵榪涜鐩稿簲鐨勯厤緗紝鏉ヨ揪鍒版鐩殑銆?br />榪欏氨瑕佺敤鍒?lt;security-constraint></security-constraint>鍏冪礌銆?br />瀵逛簬tomcat錛屼腑web.xml浣跨敤security-constraint鍏冪礌闇瑕佸湪浣嶄簬<Tomcat-installation-directory>/conf/tomcat-users.xml鐨刋ML鏂囦歡涓垱寤虹敤鎴峰悕鍜屽瘑鐮併傛瘮濡備笅闈㈢殑榪欎釜tomcat-users.xml鏂囦歡錛?br /><?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,manager"/>
  <user username="admin" password="admin" roles="admin"/>
</tomcat-users>
姝ML鐗囨鍖呮嫭涓涓猼omcat-users鏍瑰厓绱狅紝瀹冨寘鍚竴涓垨澶氫釜role鍜寀ser鍏冪礌銆?/p>

鐒跺悗鍦╓eb搴旂敤紼嬪簭鐨剋eb.xml涓垱寤簊ecurity-constraint銆乴ogin-config鍜宻ecurity-role鍏冪礌銆?/p>

<security-constraint>
      <web-resource-collection>
          <web-resource-name>HelloServlet</web-resource-name>
          <url-pattern>/HelloServlet</url-pattern>
          <http-method>GET</http-method>
          <http-method>POST</http-method>
      </web-resource-collection>
      <auth-constraint>
          <description>This applies only to the "tomcat" security role</description>
          <role-name>admin</role-name>
      </auth-constraint>
      <user-data-constraint>
          <transport-guarantee>NONE</transport-guarantee>
      </user-data-constraint>
  </security-constraint>
 
  <login-config>
      <auth-method>BASIC</auth-method>
  </login-config>
  <security-role>
      <role-name>admin</role-name>
  </security-role>

鍏朵腑security-constraint鍏冪礌鍖呭惈涓涓垨澶氫釜web-resource-collection鍏冪礌錛屽畠鏄弿榪癢eb搴旂敤紼嬪簭涓殑鍝簺web璧勬簮鍙楀埌鎸囧畾瀹夊叏闄愬埗鐨勪繚鎶ゃ俬ttp-method鍏冪礌鎸囧畾瀹夊叏闄愬埗瑕嗙洊鐨凥TTP鏂規硶銆備笂闈㈢殑渚嬪瓙涓紝褰撴垜浠/HelloServlet鐨凣ET鎴朠OST璇鋒眰鏃跺皢瑙﹀彂閰嶇疆鐨勫畨鍏ㄦ満鍒躲?br />auth-constraint鍏冪礌鐢ㄤ簬鎻忚堪鍏佽璁塊棶Web緇勪歡鐨勫畨鍏ㄨ鑹層傛渚嬩腑瀹夊叏瑙掕壊鐨勪緥瀛愭湁tomcat銆乵anager銆乤dmin銆傝屽彧鏈夊綋浣滀負admin瑙掕壊鐨勭敤鎴鋒墠鍙互璁塊棶HelloServlet銆?/p>

Web搴旂敤紼嬪簭閫氳繃login-config鍏冪礌鏉ヨ璇佺敤鎴鳳紝騫剁‘璁よ鐢ㄦ埛鏄惁涓烘紜殑瑙掕壊銆?br />longin-config鍖呭惈鐨則ransport-guarantee瀛愬厓绱犵敤鏉ユ寚瀹氳璇佹柟娉曪紝BASIC鏄竴縐嶅父瑙佺殑Web璁よ瘉鏂瑰紡錛屾祻瑙堝櫒緇欑敤鎴鋒彁紺轟竴涓璇濇錛岃姹傝緭鍏ョ敤鎴峰悕鍜屽瘑鐮侊紝闅忓悗Tomcat灝嗙粰鍑虹殑鐢ㄦ埛鍚嶅拰瀵嗙爜涓巘omcat-users.xml涓殑鐢ㄦ埛鍚嶅拰瀵嗙爜榪涜姣旇緝錛岀劧鍚庝嬌鐢ㄥ墠闈㈢殑security-constraint閰嶇疆鏉ョ‘瀹氱敤鎴鋒槸鍚﹀彲璁塊棶鍙椾繚鎶ょ殑servlet銆?/p>

錛堥櫎BASIC澶栵紝榪樺彲浠ユ槸FORM銆丆LIENT-CERT銆丏IGEST絳夛級

鍏跺疄榪欑璁よ瘉鏂規硶瀹為檯涓婃湁涓や釜姝ラ錛?br />1銆佹鏌ユ彁渚涚殑鐢ㄦ埛鍚嶅拰瀵嗙爜鏄惁姝g‘銆?br />2銆佸垽鏂敤鎴鋒槸鍚︽槧灝勫埌鐗瑰畾鐨勫畨鍏ㄨ鑹層備緥濡傦紝鐢ㄦ埛鍙兘鎻愪緵浜嗘紜殑鐢ㄦ埛鍚嶅拰瀵嗙爜錛屼絾娌℃湁鏄犲皠鍒扮壒瀹氱殑瀹夊叏瑙掕壊錛屼篃灝嗚紱佹璁塊棶鐗瑰畾鐨刉eb璧勬簮銆?br /> 



googlor 2006-12-08 11:41 鍙戣〃璇勮
]]>
綆鍗曞伐鍘傛ā寮忋佸伐鍘傛ā寮忋?鎶借薄宸ュ巶妯″紡http://www.aygfsteel.com/leishiran/articles/30135.htmlgooglorgooglorFri, 10 Feb 2006 06:42:00 GMThttp://www.aygfsteel.com/leishiran/articles/30135.htmlhttp://www.aygfsteel.com/leishiran/comments/30135.htmlhttp://www.aygfsteel.com/leishiran/articles/30135.html#Feedback0http://www.aygfsteel.com/leishiran/comments/commentRss/30135.htmlhttp://www.aygfsteel.com/leishiran/services/trackbacks/30135.html
綆鍗曞伐鍘傛ā寮忓氨鏄敱涓涓伐鍘傜被鏍規嵁鍙傛暟鏉ュ喅瀹氬垱绔嬪嚭閭d竴縐嶄駭鍝佺被鐨勫疄渚嬨備笅闈㈢殑UML綾誨浘灝辯簿紜畾涔変簡綆鍗曞伐鍘傛ā寮忕殑緇撴瀯銆?BR>


渚嬪錛?BR>
浠g爜錛?BR>package com.javapatterns.simplefactory.exercise;

public class ArtTracer
{
銆public Shape factory(String which) throws BadShapeException
銆{
銆銆if (which.equalsIgnoreCase("circle"))
銆銆{
銆銆銆return new Circle();
銆銆}
銆銆else if (which.equalsIgnoreCase("square"))
銆銆{
銆銆銆return new Square();
銆銆}
銆銆else if (which.equalsIgnoreCase("triangle"))
銆銆{
銆銆銆return new Triangle();
銆銆}
銆銆else
銆銆{
銆銆銆throw new BadShapeException(which);
銆銆}
銆}
}


package com.javapatterns.simplefactory.exercise;

public interface Shape
{
銆void draw();

銆void erase();
}

package com.javapatterns.simplefactory.exercise;

銆public class Square implements Shape
銆{
銆銆public void draw()
銆銆{
銆銆銆System.out.println("Square.draw()");
銆銆}

銆public void erase()
銆{
銆銆System.out.println("Square.erase()");
銆}
}

package com.javapatterns.simplefactory.exercise;

public class BadShapeException extends Exception
{
銆public BadShapeException(String msg)
銆{
銆銆super(msg);
銆}
}


鎻忓浘鍛?Art Tracer)緋葷粺浣跨敤鏂規硶濡備笅

try
{
ArtTracer art = new ArtTracer();

art.factory("circle");
art.factory("square");
art.factory("triangle");

art.factory("diamond");
}
catch(BadShapeException e)
{
...
}


2銆傚伐鍘傛ā寮?BR>3銆傛娊璞″伐鍘傛ā寮?

googlor 2006-02-10 14:42 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 嘉峪关市| 古交市| 饶阳县| 青海省| 柳河县| 绵阳市| 始兴县| 禄劝| 饶阳县| 长汀县| 龙岩市| 益阳市| 孝昌县| 建昌县| 怀柔区| 上蔡县| 云和县| 石景山区| 绵竹市| 廊坊市| 丹江口市| 达拉特旗| 罗山县| 萨嘎县| 赞皇县| 金溪县| 库尔勒市| 德化县| 沅江市| 临夏县| 清原| 连城县| 莲花县| 田东县| 蒙山县| 湄潭县| 湖南省| 吴江市| 莱西市| 定兴县| 昌都县|