url鏄犲皠 ccf 锛圝ava姝e垯琛ㄨ揪寮忚В娉曪級

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了url鏄犲皠 ccf 锛圝ava姝e垯琛ㄨ揪寮忚В娉曪級相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/dHash' title='dHash'>dHash   body   set   pre   add   data   lsp   鍦板潃   scan   

闂鎻忚堪

璇曢缂栧彿锛?/td> 201803-3
璇曢鍚嶇О锛?/td> URL鏄犲皠
鏃堕棿闄愬埗锛?/td> 1.0s
鍐呭瓨闄愬埗锛?/td> 256.0MB
闂鎻忚堪锛?/td>
闂鎻忚堪
銆€銆€URL 鏄犲皠鏄濡?Django銆丷uby on Rails 绛夌綉椤垫鏋?(web frameworks) 鐨勪竴涓噸瑕佺粍浠躲€傚浜庝粠娴忚鍣ㄥ彂鏉ョ殑 HTTP 璇锋眰锛孶RL 鏄犲皠妯″潡浼氳В鏋愯姹備腑鐨?URL 鍦板潃锛屽苟灏嗗叾鍒嗘淳缁欑浉搴旂殑澶勭悊浠g爜銆傜幇鍦紝璇蜂綘鏉ュ疄鐜颁竴涓畝鍗曠殑 URL 鏄犲皠鍔熻兘銆?br />銆€銆€鏈涓?URL 鏄犲皠鍔熻兘鐨勯厤缃敱鑻ュ共鏉?URL 鏄犲皠瑙勫垯缁勬垚銆傚綋涓€涓姹傚埌杈炬椂锛孶RL 鏄犲皠鍔熻兘浼氬皢璇锋眰涓殑 URL 鍦板潃鎸夌収閰嶇疆鐨勫厛鍚庨『搴忛€愪竴涓庤繖浜涜鍒欒繘琛屽尮閰嶃€傚綋閬囧埌绗竴鏉″畬鍏ㄥ尮閰嶇殑瑙勫垯鏃讹紝鍖归厤鎴愬姛锛屽緱鍒板尮閰嶇殑瑙勫垯浠ュ強鍖归厤鐨勫弬鏁般€傝嫢涓嶈兘鍖归厤浠讳綍涓€鏉¤鍒欙紝鍒欏尮閰嶅け璐ャ€?br />銆€銆€鏈杈撳叆鐨?URL 鍦板潃鏄互鏂滄潬 / 浣滀负鍒嗛殧绗︾殑璺緞锛屼繚璇佷互鏂滄潬寮€澶淬€傚叾浠栧悎娉曞瓧绗﹁繕鍖呮嫭澶у皬鍐欒嫳鏂囧瓧姣嶃€侀樋鎷変集鏁板瓧銆佸噺鍙?-銆佷笅鍒掔嚎 _ 鍜屽皬鏁扮偣 .銆備緥濡傦紝/person/123/ 鏄竴涓悎娉曠殑 URL 鍦板潃锛岃€?/person/123? 鍒欎笉鍚堟硶锛堝瓨鍦ㄤ笉鍚堟硶鐨勫瓧绗﹂棶鍙??锛夈€傚彟澶栵紝鑻辨枃瀛楁瘝鍖哄垎澶у皬鍐欙紝鍥犳 /case/ 鍜?/CAse/ 鏄笉鍚岀殑 URL 鍦板潃銆?br />銆€銆€瀵逛簬 URL 鏄犲皠瑙勫垯锛屽悓鏍锋槸浠ユ枩鏉犲紑濮嬨€傞櫎浜嗗彲浠ユ槸姝e父鐨?URL 鍦板潃澶栵紝杩樺彲浠ュ寘鍚弬鏁帮紝鏈変互涓?3 绉嶏細
銆€銆€瀛楃涓?<str>锛氱敤浜庡尮閰嶄竴娈靛瓧绗︿覆锛屾敞鎰忓瓧绗︿覆閲屼笉鑳藉寘鍚枩鏉犮€備緥濡傦紝abcde0123銆?br />銆€銆€鏁存暟 <int>锛氱敤浜庡尮閰嶄竴涓笉甯︾鍙风殑鏁存暟锛屽叏閮ㄧ敱闃挎媺浼暟瀛楃粍鎴愩€備緥濡傦紝01234銆?br />銆€銆€璺緞 <path>锛氱敤浜庡尮閰嶄竴娈靛瓧绗︿覆锛屽瓧绗︿覆鍙互鍖呭惈鏂滄潬銆備緥濡傦紝abcd/0123/銆?br />銆€銆€浠ヤ笂 3 绉嶅弬鏁伴兘蹇呴』鍖归厤闈炵┖鐨勫瓧绗︿覆銆傜畝渚胯捣瑙侊紝棰樼洰瑙勫畾瑙勫垯涓?<str> 鍜?<int> 鍓嶉潰涓€瀹氭槸鏂滄潬锛屽悗闈㈣涔堟槸鏂滄潬锛岃涔堟槸瑙勫垯鐨勭粨鏉燂紙涔熷氨鏄鍙傛暟鏄鍒欑殑鏈€鍚庝竴閮ㄥ垎锛夈€傝€?<path> 鐨勫墠闈竴瀹氭槸鏂滄潬锛屽悗闈竴瀹氭槸瑙勫垯鐨勭粨鏉熴€傛棤璁烘槸 URL 鍦板潃杩樻槸瑙勫垯锛岄兘涓嶄細鍑虹幇杩炵画鐨勬枩鏉犮€?/div>
杈撳叆鏍煎紡
銆€銆€杈撳叆绗竴琛屾槸涓や釜姝f暣鏁?nbsp;n 鍜?nbsp;m锛屽垎鍒〃绀?URL 鏄犲皠鐨勮鍒欐潯鏁板拰寰呭鐞嗙殑 URL 鍦板潃涓暟锛屼腑闂寸敤涓€涓┖鏍煎瓧绗﹀垎闅斻€?br />銆€銆€绗?2 琛岃嚦绗?nbsp;n+1 琛屾寜鍖归厤鐨勫厛鍚庨『搴忔弿杩?URL 鏄犲皠瑙勫垯鐨勯厤缃俊鎭€傜 i+1 琛屽寘鍚袱涓瓧绗︿覆 pi 鍜?nbsp;ri锛屽叾涓?nbsp;pi 琛ㄧず URL 鍖归厤鐨勮鍒欙紝ri 琛ㄧず杩欐潯 URL 鍖归厤鐨勫悕瀛椼€備袱涓瓧绗︿覆閮介潪绌猴紝涓斾笉鍖呭惈绌烘牸瀛楃锛屼袱鑰呬腑闂寸敤涓€涓┖鏍煎瓧绗﹀垎闅斻€?br />銆€銆€绗?nbsp;n+2 琛岃嚦绗?nbsp;n+m+1 琛屾弿杩板緟澶勭悊鐨?URL 鍦板潃銆傜 n+1+i 琛屽寘鍚竴涓瓧绗︿覆 qi锛岃〃绀哄緟澶勭悊鐨?URL 鍦板潃锛屽瓧绗︿覆涓笉鍖呭惈绌烘牸瀛楃銆?/div>
杈撳嚭鏍煎紡
銆€銆€杈撳叆鍏?nbsp;m 琛岋紝绗?nbsp;i 琛岃〃绀?nbsp;qi 鐨勫尮閰嶇粨鏋溿€傚鏋滃尮閰嶆垚鍔燂紝璁惧尮閰嶄簡瑙勫垯 pj 锛屽垯杈撳嚭瀵瑰簲鐨?nbsp;rj銆傚悓鏃讹紝濡傛灉瑙勫垯涓湁鍙傛暟锛屽垯鍦ㄥ悓涓€琛屽唴渚濇杈撳嚭鍖归厤鍚庣殑鍙傛暟銆傛敞鎰忔暣鏁板弬鏁拌緭鍑烘椂瑕佹妸鍓嶅闆跺幓鎺夈€傜浉閭讳袱椤逛箣闂寸敤涓€涓┖鏍煎瓧绗﹀垎闅斻€傚鏋滃尮閰嶅け璐ワ紝鍒欒緭鍑?404銆?/div>
鏍蜂緥杈撳叆
5 4
/articles/2003/ special_case_2003
/articles/<int>/ year_archive
/articles/<int>/<int>/ month_archive
/articles/<int>/<int>/<str>/ article_detail
/static/<path> static_serve
/articles/2004/
/articles/1985/09/aloha/
/articles/hello/
/static/js/jquery.js
鏍蜂緥杈撳嚭
year_archive 2004
article_detail 1985 9 aloha
404
static_serve js/jquery.js
鏍蜂緥璇存槑
銆€銆€瀵逛簬绗?1 涓湴鍧€ /articles/2004/锛屾棤娉曞尮閰嶇 1 鏉¤鍒欙紝鍙互鍖归厤绗?2 鏉¤鍒欙紝鍙傛暟涓?2004銆?br />銆€銆€瀵逛簬绗?2 涓湴鍧€ /articles/1985/09/aloha/锛屽彧鑳藉尮閰嶇 4 鏉¤鍒欙紝鍙傛暟渚濇涓?1985銆?锛堝凡缁忓幓鎺夊墠瀵奸浂锛夊拰 aloha銆?br />銆€銆€瀵逛簬绗?3 涓湴鍧€ /articles/hello/锛屾棤娉曞尮閰嶄换浣曚竴鏉¤鍒欍€?br />銆€銆€瀵逛簬绗?4 涓湴鍧€ /static/js/jquery.js锛屽彲浠ュ尮閰嶆渶鍚庝竴鏉¤鍒欙紝鍙傛暟涓?js/jquery.js銆?/div>
鏁版嵁瑙勬ā鍜岀害瀹?/div>
銆€銆€1 ≤ n ≤ 100锛? ≤ m ≤ 100銆?br />銆€銆€鎵€鏈夎緭鍏ヨ鐨勯暱搴︿笉瓒呰繃 100 涓瓧绗︼紙涓嶅寘鍚崲琛岀锛夈€?br />銆€銆€淇濊瘉杈撳叆鐨勮鍒欓兘鏄悎娉曠殑銆?/div>

 

鎶婂瓧绗︿覆鐨勫墠瀵?涔熷幓鎺変簡锛?0鍒嗐€傘€傘€?/p>

 1 import java.util.LinkedHashMap;
 2 import java.util.Map;
 3 import java.util.Scanner;
 4 import java.util.regex.Matcher;
 5 import java.util.regex.Pattern;
 6 
 7 
 8 public class Main {
 9 
10     public static void main(String[] args) {
11         int n, m;
12         int flag = 0;
13         Scanner sc = new Scanner(System.in);
14         n = sc.nextInt();
15         m = sc.nextInt();
16         sc.nextLine();
17         LinkedHashMap<String, String> mp = new LinkedHashMap<>();
18         for (int i = 1; i <= n; ++i) {
19             String line = sc.nextLine();
20             String[] arr = line.split(" ");
21             mp.put(arr[0], arr[1]);
22         }
23 
24         for (int i = 1; i <= m; ++i) {
25             String line = sc.nextLine();
26             for (Map.Entry<String, String> en : mp.entrySet()) {
27                 String regex = en.getKey();
28                 regex = regex.replace("<int>", "(\d+)");
29                 regex = regex.replace("<str>", "(.+)");
30                 regex = regex.replace("<path>", "(.+)");
31                 if(line.matches(regex)) {    // 瀹屽叏鍖归厤
32                     flag = 1;
33                     Pattern p = Pattern.compile(regex);
34                     Matcher mat = p.matcher(line);
35                     while (mat.find()) {    
36                         System.out.print(en.getValue());
37                         for (int j = 1; j <= mat.groupCount(); ++j) {
38                             String str = mat.group(j);
39                     //        if(str.matches("\d+"))
40                             str = str.replaceAll("^0+", "");    // 鍘绘帀鏁板瓧鍓嶉潰鐨? (瀛楃涓插墠闈㈢殑0涔熷幓鎺変簡)
41                             System.out.print(" " + str);
42                         }
43                         System.out.println();
44                     }
45                     break;
46                 }
47             }
48             if(flag == 0)
49                 System.out.println(404);
50             else
51                 flag = 0;    // 閲嶇疆flag
52         }
53 
54     }
55 
56 }

 

以上是关于url鏄犲皠 ccf 锛圝ava姝e垯琛ㄨ揪寮忚В娉曪級的主要内容,如果未能解决你的问题,请参考以下文章

姝e垯琛ㄨ揪寮?java)瑙勫垯澶у叏

spring鍩轰簬@Value缁戝畾灞濨ean鎬уけ

macOS閿洏鏄犲皠

Photon Server鍒濊瘑(涓? ---ORM鏄犲皠鏀硅繘

Zuul鐨勪娇鐢紝璺敱璁块棶鏄犲皠瑙勫垯

寮傚父鈥斺€攃md涓媕avac閿欒锛氱紪鐮丟BK涓嶅彲鏄犲皠瀛楃