web.html 204.6 KB
Newer Older
茶陵後's avatar
茶陵後 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Web | Spring Docs</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" type="image/png" sizes="16x16" href="/images/icons/favicon.ico">
    <link rel="icon" type="image/png" sizes="48x48" href="/images/icons/icon-48x48.png">
    <link rel="icon" type="image/png" sizes="72x72" href="/images/icons/icon-72x72.png">
    <link rel="manifest" href="/manifest.webmanifest">
    <link rel="apple-touch-icon" href="/images/icons/icon_48x48.png">
    <link rel="mask-icon" href="/images/icons/favicon.ico" color="#5dac38">
    <script>
    var _hmt = _hmt || [];
    (function () {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?8eefd6b163dcb3f5762af6b0825e2dd1";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
    </script>
    <meta name="description" content="Spring Boot is well suited for web application development.
You can create a self-contained HTTP server by using embedded Tomcat, Jetty, Undertow, or Netty.
Most web applications use the spring-boot-starter-web module to get up and running quickly.
You can also choose to build reactive web applications by using the spring-boot-starter-webflux module.">
    <meta name="twitter:title" content="Web">
    <meta name="twitter:description" content="Spring Boot is well suited for web application development.
You can create a self-contained HTTP server by using embedded Tomcat, Jetty, Undertow, or Netty.
Most web applications use the spring-boot-starter-web module to get up and running quickly.
You can also choose to build reactive web applications by using the spring-boot-starter-webflux module.">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:url" content="https://spring.gitcode.net/en/spring-boot/web.html">
    <meta property="og:type" content="article">
    <meta property="og:title" content="Web">
    <meta property="og:description" content="Spring Boot is well suited for web application development.
You can create a self-contained HTTP server by using embedded Tomcat, Jetty, Undertow, or Netty.
Most web applications use the spring-boot-starter-web module to get up and running quickly.
You can also choose to build reactive web applications by using the spring-boot-starter-webflux module.">
    <meta property="og:url" content="https://spring.gitcode.net/en/spring-boot/web.html">
    <meta property="og:site_name" content="Spring 中文文档社区">
    <meta itemprop="name" content="Web">
    <meta itemprop="description" content="Spring Boot is well suited for web application development.
You can create a self-contained HTTP server by using embedded Tomcat, Jetty, Undertow, or Netty.
Most web applications use the spring-boot-starter-web module to get up and running quickly.
You can also choose to build reactive web applications by using the spring-boot-starter-webflux module.">
    <meta name="application-name" content="Spring 中文文档社区">
    <meta name="apple-mobile-web-app-title" content="Spring 中文社区">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileColor" content="#5dac38">
    <meta name="theme-color" content="#5dac38">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="baidu-site-verification" content="code-tApgxyb9G8">
    
    <link rel="preload" href="/assets/css/0.styles.af3770e9.css" as="style"><link rel="preload" href="/assets/js/app.cf11b18e.js" as="script"><link rel="preload" href="/assets/js/3.50918073.js" as="script"><link rel="preload" href="/assets/js/4.cd4c3ff4.js" as="script"><link rel="preload" href="/assets/js/59.9079a4f5.js" as="script"><link rel="prefetch" href="/assets/js/10.675f4d7e.js"><link rel="prefetch" href="/assets/js/100.89ddf0f9.js"><link rel="prefetch" href="/assets/js/101.a2584c55.js"><link rel="prefetch" href="/assets/js/102.53225958.js"><link rel="prefetch" href="/assets/js/103.be06048d.js"><link rel="prefetch" href="/assets/js/104.a2328e06.js"><link rel="prefetch" href="/assets/js/105.78529341.js"><link rel="prefetch" href="/assets/js/106.fc779386.js"><link rel="prefetch" href="/assets/js/107.375c8dec.js"><link rel="prefetch" href="/assets/js/108.cf4ca7e2.js"><link rel="prefetch" href="/assets/js/109.f4d3964d.js"><link rel="prefetch" href="/assets/js/11.b58e279a.js"><link rel="prefetch" href="/assets/js/110.4ae56c4d.js"><link rel="prefetch" href="/assets/js/111.baf7121d.js"><link rel="prefetch" href="/assets/js/112.a963ade8.js"><link rel="prefetch" href="/assets/js/113.edbb458c.js"><link rel="prefetch" href="/assets/js/114.7e2b354f.js"><link rel="prefetch" href="/assets/js/115.4e41285c.js"><link rel="prefetch" href="/assets/js/116.1ee84ed6.js"><link rel="prefetch" href="/assets/js/117.4952cce2.js"><link rel="prefetch" href="/assets/js/118.306eabfa.js"><link rel="prefetch" href="/assets/js/119.5a4712e9.js"><link rel="prefetch" href="/assets/js/12.c41ab7bc.js"><link rel="prefetch" href="/assets/js/120.496c9660.js"><link rel="prefetch" href="/assets/js/121.e4a22135.js"><link rel="prefetch" href="/assets/js/122.02f82a94.js"><link rel="prefetch" href="/assets/js/123.53c5a24e.js"><link rel="prefetch" href="/assets/js/124.11d8be3e.js"><link rel="prefetch" href="/assets/js/125.c0740874.js"><link rel="prefetch" href="/assets/js/126.9cb2911c.js"><link rel="prefetch" href="/assets/js/127.6f87a638.js"><link rel="prefetch" href="/assets/js/128.456206df.js"><link rel="prefetch" href="/assets/js/129.ce51dc7d.js"><link rel="prefetch" href="/assets/js/13.1147a447.js"><link rel="prefetch" href="/assets/js/130.66718f4c.js"><link rel="prefetch" href="/assets/js/131.713226b7.js"><link rel="prefetch" href="/assets/js/132.6e2b68e3.js"><link rel="prefetch" href="/assets/js/133.11148e38.js"><link rel="prefetch" href="/assets/js/134.8de25763.js"><link rel="prefetch" href="/assets/js/135.961f6693.js"><link rel="prefetch" href="/assets/js/136.8abc4532.js"><link rel="prefetch" href="/assets/js/137.331bfb6b.js"><link rel="prefetch" href="/assets/js/138.f76ee7b9.js"><link rel="prefetch" href="/assets/js/139.578aa70e.js"><link rel="prefetch" href="/assets/js/14.1c437f54.js"><link rel="prefetch" href="/assets/js/140.9f1f28a0.js"><link rel="prefetch" href="/assets/js/141.b08ac1ec.js"><link rel="prefetch" href="/assets/js/142.e5c934cf.js"><link rel="prefetch" href="/assets/js/143.2a9d47c6.js"><link rel="prefetch" href="/assets/js/144.76090f65.js"><link rel="prefetch" href="/assets/js/145.41a54d41.js"><link rel="prefetch" href="/assets/js/146.979b34c1.js"><link rel="prefetch" href="/assets/js/147.46e366af.js"><link rel="prefetch" href="/assets/js/148.efcd2b17.js"><link rel="prefetch" href="/assets/js/149.04135c0b.js"><link rel="prefetch" href="/assets/js/15.cbd21f6a.js"><link rel="prefetch" href="/assets/js/150.679d76bf.js"><link rel="prefetch" href="/assets/js/151.2b0748da.js"><link rel="prefetch" href="/assets/js/152.cee5bbcd.js"><link rel="prefetch" href="/assets/js/153.680b4156.js"><link rel="prefetch" href="/assets/js/154.0c6972fe.js"><link rel="prefetch" href="/assets/js/155.35a3e5ab.js"><link rel="prefetch" href="/assets/js/156.6782d874.js"><link rel="prefetch" href="/assets/js/157.b9fe2583.js"><link rel="prefetch" href="/assets/js/158.96656194.js"><link rel="prefetch" href="/assets/js/159.2a0f7744.js"><link rel="prefetch" href="/assets/js/16.0cc4679e.js"><link rel="prefetch" href="/assets/js/160.c26bf909.js"><link rel="prefetch" href="/assets/js/161.45a3950a.js"><link rel="prefetch" href="/assets/js/162.4a08c069.js"><link rel="prefetch" href="/assets/js/163.a540d00c.js"><link rel="prefetch" href="/assets/js/164.117eb7b8.js"><link rel="prefetch" href="/assets/js/165.4fabe2ea.js"><link rel="prefetch" href="/assets/js/166.27d3bfe9.js"><link rel="prefetch" href="/assets/js/167.c8a74627.js"><link rel="prefetch" href="/assets/js/168.e16111b9.js"><link rel="prefetch" href="/assets/js/169.458ea1d8.js"><link rel="prefetch" href="/assets/js/17.d3f5977b.js"><link rel="prefetch" href="/assets/js/170.4b38adcf.js"><link rel="prefetch" href="/assets/js/171.98cb45b7.js"><link rel="prefetch" href="/assets/js/172.9ca2eb1a.js"><link rel="prefetch" href="/assets/js/173.14074c7f.js"><link rel="prefetch" href="/assets/js/174.8e1f9887.js"><link rel="prefetch" href="/assets/js/175.5989a4ca.js"><link rel="prefetch" href="/assets/js/176.89b35f24.js"><link rel="prefetch" href="/assets/js/177.8ca04666.js"><link rel="prefetch" href="/assets/js/178.f1f78ad5.js"><link rel="prefetch" href="/assets/js/179.a1faadfe.js"><link rel="prefetch" href="/assets/js/18.1a2bbade.js"><link rel="prefetch" href="/assets/js/180.33be0a0d.js"><link rel="prefetch" href="/assets/js/181.074198fc.js"><link rel="prefetch" href="/assets/js/182.2ea92f58.js"><link rel="prefetch" href="/assets/js/183.316f0529.js"><link rel="prefetch" href="/assets/js/184.f6dd5f36.js"><link rel="prefetch" href="/assets/js/185.134f1457.js"><link rel="prefetch" href="/assets/js/186.2aa74077.js"><link rel="prefetch" href="/assets/js/187.3a956aba.js"><link rel="prefetch" href="/assets/js/188.01a6573f.js"><link rel="prefetch" href="/assets/js/189.a8d65b4d.js"><link rel="prefetch" href="/assets/js/19.e062ea88.js"><link rel="prefetch" href="/assets/js/190.c753d8e3.js"><link rel="prefetch" href="/assets/js/191.280fe1e2.js"><link rel="prefetch" href="/assets/js/192.bbc94e32.js"><link rel="prefetch" href="/assets/js/193.41421d14.js"><link rel="prefetch" href="/assets/js/194.15f508e4.js"><link rel="prefetch" href="/assets/js/195.a17f3877.js"><link rel="prefetch" href="/assets/js/196.d17bfcdf.js"><link rel="prefetch" href="/assets/js/197.65791a5a.js"><link rel="prefetch" href="/assets/js/198.0441041e.js"><link rel="prefetch" href="/assets/js/199.538f2285.js"><link rel="prefetch" href="/assets/js/20.6c49f026.js"><link rel="prefetch" href="/assets/js/200.4ff8dbc4.js"><link rel="prefetch" href="/assets/js/201.088ccf86.js"><link rel="prefetch" href="/assets/js/202.8bdad311.js"><link rel="prefetch" href="/assets/js/203.45d3ecc5.js"><link rel="prefetch" href="/assets/js/204.c403aa39.js"><link rel="prefetch" href="/assets/js/205.e992b689.js"><link rel="prefetch" href="/assets/js/206.eed8bd42.js"><link rel="prefetch" href="/assets/js/207.3db1fc87.js"><link rel="prefetch" href="/assets/js/208.27399a7b.js"><link rel="prefetch" href="/assets/js/209.829f007c.js"><link rel="prefetch" href="/assets/js/21.0ed0e55b.js"><link rel="prefetch" href="/assets/js/210.35079683.js"><link rel="prefetch" href="/assets/js/211.94056191.js"><link rel="prefetch" href="/assets/js/212.431059ab.js"><link rel="prefetch" href="/assets/js/213.4d25e21f.js"><link rel="prefetch" href="/assets/js/214.e62f8fc5.js"><link rel="prefetch" href="/assets/js/215.433d7113.js"><link rel="prefetch" href="/assets/js/216.6de56c4d.js"><link rel="prefetch" href="/assets/js/217.ad3e1cd0.js"><link rel="prefetch" href="/assets/js/218.c225521d.js"><link rel="prefetch" href="/assets/js/219.f4241738.js"><link rel="prefetch" href="/assets/js/22.3563c6e0.js"><link rel="prefetch" href="/assets/js/220.ac9c6899.js"><link rel="prefetch" href="/assets/js/221.ff4ee0d2.js"><link rel="prefetch" href="/assets/js/222.20629300.js"><link rel="prefetch" href="/assets/js/223.a5fa0166.js"><link rel="prefetch" href="/assets/js/224.65290c4f.js"><link rel="prefetch" href="/assets/js/225.e698f717.js"><link rel="prefetch" href="/assets/js/226.4b28f10d.js"><link rel="prefetch" href="/assets/js/227.f44065ae.js"><link rel="prefetch" href="/assets/js/228.0b254d68.js"><link rel="prefetch" href="/assets/js/229.560ccb5c.js"><link rel="prefetch" href="/assets/js/23.2bc6a9e3.js"><link rel="prefetch" href="/assets/js/230.2e09449c.js"><link rel="prefetch" href="/assets/js/231.b09e3f00.js"><link rel="prefetch" href="/assets/js/232.eaa54385.js"><link rel="prefetch" href="/assets/js/233.36843a48.js"><link rel="prefetch" href="/assets/js/234.1e3e41c7.js"><link rel="prefetch" href="/assets/js/235.2dff4846.js"><link rel="prefetch" href="/assets/js/236.bb6fd980.js"><link rel="prefetch" href="/assets/js/237.e97364da.js"><link rel="prefetch" href="/assets/js/238.d8ce22f3.js"><link rel="prefetch" href="/assets/js/239.be791e5e.js"><link rel="prefetch" href="/assets/js/24.4b60795e.js"><link rel="prefetch" href="/assets/js/240.3927116f.js"><link rel="prefetch" href="/assets/js/241.6539a7f9.js"><link rel="prefetch" href="/assets/js/242.1241e424.js"><link rel="prefetch" href="/assets/js/243.a07d3be3.js"><link rel="prefetch" href="/assets/js/244.f98f98a1.js"><link rel="prefetch" href="/assets/js/245.ecb7c922.js"><link rel="prefetch" href="/assets/js/246.95ed23ce.js"><link rel="prefetch" href="/assets/js/247.fb5d42c6.js"><link rel="prefetch" href="/assets/js/248.f7b4f364.js"><link rel="prefetch" href="/assets/js/249.ac22d922.js"><link rel="prefetch" href="/assets/js/25.ef18cc01.js"><link rel="prefetch" href="/assets/js/250.01fbf76b.js"><link rel="prefetch" href="/assets/js/251.08f19bbd.js"><link rel="prefetch" href="/assets/js/252.9f11061d.js"><link rel="prefetch" href="/assets/js/253.cd7f85b9.js"><link rel="prefetch" href="/assets/js/254.2493e550.js"><link rel="prefetch" href="/assets/js/255.ac6d41ee.js"><link rel="prefetch" href="/assets/js/256.068eb5a6.js"><link rel="prefetch" href="/assets/js/257.b108c715.js"><link rel="prefetch" href="/assets/js/258.d614b5d4.js"><link rel="prefetch" href="/assets/js/259.87ba5ef3.js"><link rel="prefetch" href="/assets/js/26.5baa4d2c.js"><link rel="prefetch" href="/assets/js/260.c771e39d.js"><link rel="prefetch" href="/assets/js/261.0dbaf460.js"><link rel="prefetch" href="/assets/js/262.35e64a26.js"><link rel="prefetch" href="/assets/js/263.c16fca32.js"><link rel="prefetch" href="/assets/js/264.ea414912.js"><link rel="prefetch" href="/assets/js/265.f2e0d5bb.js"><link rel="prefetch" href="/assets/js/266.629a2d15.js"><link rel="prefetch" href="/assets/js/267.c7332e80.js"><link rel="prefetch" href="/assets/js/268.8be99f76.js"><link rel="prefetch" href="/assets/js/269.452ff2d4.js"><link rel="prefetch" href="/assets/js/27.2a2950d8.js"><link rel="prefetch" href="/assets/js/270.a5c429cb.js"><link rel="prefetch" href="/assets/js/271.1ad3cd83.js"><link rel="prefetch" href="/assets/js/272.354cef59.js"><link rel="prefetch" href="/assets/js/273.681156b7.js"><link rel="prefetch" href="/assets/js/274.6c51e7ae.js"><link rel="prefetch" href="/assets/js/275.24ef01b4.js"><link rel="prefetch" href="/assets/js/276.afeb2acd.js"><link rel="prefetch" href="/assets/js/277.6472c22d.js"><link rel="prefetch" href="/assets/js/278.416d9788.js"><link rel="prefetch" href="/assets/js/279.c190fbc9.js"><link rel="prefetch" href="/assets/js/28.6320d8c1.js"><link rel="prefetch" href="/assets/js/280.28b1b955.js"><link rel="prefetch" href="/assets/js/281.77afd7c5.js"><link rel="prefetch" href="/assets/js/282.eee0e9c0.js"><link rel="prefetch" href="/assets/js/283.e59fb0e5.js"><link rel="prefetch" href="/assets/js/284.9c6ff275.js"><link rel="prefetch" href="/assets/js/285.3e2d030a.js"><link rel="prefetch" href="/assets/js/286.d7562f9b.js"><link rel="prefetch" href="/assets/js/287.9e228e80.js"><link rel="prefetch" href="/assets/js/288.f9448d7d.js"><link rel="prefetch" href="/assets/js/289.30726f95.js"><link rel="prefetch" href="/assets/js/29.a420635f.js"><link rel="prefetch" href="/assets/js/290.f79765e2.js"><link rel="prefetch" href="/assets/js/291.0943618c.js"><link rel="prefetch" href="/assets/js/292.bd04f6db.js"><link rel="prefetch" href="/assets/js/293.776f4c0d.js"><link rel="prefetch" href="/assets/js/294.54e52863.js"><link rel="prefetch" href="/assets/js/295.bd033d69.js"><link rel="prefetch" href="/assets/js/296.1090c539.js"><link rel="prefetch" href="/assets/js/297.ec37f6e8.js"><link rel="prefetch" href="/assets/js/298.fa434214.js"><link rel="prefetch" href="/assets/js/299.50bd7c87.js"><link rel="prefetch" href="/assets/js/30.6c81ca7b.js"><link rel="prefetch" href="/assets/js/300.7a2c6632.js"><link rel="prefetch" href="/assets/js/301.4ae4e645.js"><link rel="prefetch" href="/assets/js/302.e1ef7459.js"><link rel="prefetch" href="/assets/js/303.3894068b.js"><link rel="prefetch" href="/assets/js/304.840b09e3.js"><link rel="prefetch" href="/assets/js/305.40ec0bf6.js"><link rel="prefetch" href="/assets/js/306.9fa4d8aa.js"><link rel="prefetch" href="/assets/js/307.33656e76.js"><link rel="prefetch" href="/assets/js/308.19398f71.js"><link rel="prefetch" href="/assets/js/309.bde6f12f.js"><link rel="prefetch" href="/assets/js/31.2b4f2752.js"><link rel="prefetch" href="/assets/js/310.69ced632.js"><link rel="prefetch" href="/assets/js/311.c8e57d0e.js"><link rel="prefetch" href="/assets/js/312.80c4d6a7.js"><link rel="prefetch" href="/assets/js/313.14060a06.js"><link rel="prefetch" href="/assets/js/314.29165d83.js"><link rel="prefetch" href="/assets/js/315.901aabf1.js"><link rel="prefetch" href="/assets/js/316.7f0d18e3.js"><link rel="prefetch" href="/assets/js/317.112de6ec.js"><link rel="prefetch" href="/assets/js/318.091ea533.js"><link rel="prefetch" href="/assets/js/319.25ca175e.js"><link rel="prefetch" href="/assets/js/32.ab03e16f.js"><link rel="prefetch" href="/assets/js/320.b89e85c9.js"><link rel="prefetch" href="/assets/js/321.69316136.js"><link rel="prefetch" href="/assets/js/322.567512f0.js"><link rel="prefetch" href="/assets/js/323.2d67bb75.js"><link rel="prefetch" href="/assets/js/324.c41411db.js"><link rel="prefetch" href="/assets/js/325.a412ca77.js"><link rel="prefetch" href="/assets/js/326.22408ce6.js"><link rel="prefetch" href="/assets/js/327.33524443.js"><link rel="prefetch" href="/assets/js/328.561ebeb1.js"><link rel="prefetch" href="/assets/js/329.d7a280e4.js"><link rel="prefetch" href="/assets/js/33.199f45ed.js"><link rel="prefetch" href="/assets/js/330.d01a7e1b.js"><link rel="prefetch" href="/assets/js/331.a3ad2556.js"><link rel="prefetch" href="/assets/js/332.36ad912a.js"><link rel="prefetch" href="/assets/js/333.2fb229c4.js"><link rel="prefetch" href="/assets/js/334.d170f507.js"><link rel="prefetch" href="/assets/js/335.90ca0539.js"><link rel="prefetch" href="/assets/js/336.454d4374.js"><link rel="prefetch" href="/assets/js/337.dba45eb4.js"><link rel="prefetch" href="/assets/js/338.c8e4ba66.js"><link rel="prefetch" href="/assets/js/339.ae85118e.js"><link rel="prefetch" href="/assets/js/34.d0c7a02e.js"><link rel="prefetch" href="/assets/js/340.7033b85b.js"><link rel="prefetch" href="/assets/js/341.13cfe1aa.js"><link rel="prefetch" href="/assets/js/342.b33302b5.js"><link rel="prefetch" href="/assets/js/343.946f30dc.js"><link rel="prefetch" href="/assets/js/344.b2add405.js"><link rel="prefetch" href="/assets/js/345.12433fa3.js"><link rel="prefetch" href="/assets/js/346.b1bdfeba.js"><link rel="prefetch" href="/assets/js/347.53530bff.js"><link rel="prefetch" href="/assets/js/348.48aa580e.js"><link rel="prefetch" href="/assets/js/349.53c4baca.js"><link rel="prefetch" href="/assets/js/35.5512348f.js"><link rel="prefetch" href="/assets/js/350.e4b2d6e6.js"><link rel="prefetch" href="/assets/js/351.d41b01c1.js"><link rel="prefetch" href="/assets/js/352.1c4d1250.js"><link rel="prefetch" href="/assets/js/353.7fd27c0f.js"><link rel="prefetch" href="/assets/js/354.47199c90.js"><link rel="prefetch" href="/assets/js/355.68bccab4.js"><link rel="prefetch" href="/assets/js/356.e3602eb5.js"><link rel="prefetch" href="/assets/js/357.cd5ce764.js"><link rel="prefetch" href="/assets/js/358.bee621d4.js"><link rel="prefetch" href="/assets/js/359.648aa4f0.js"><link rel="prefetch" href="/assets/js/36.bdebdf29.js"><link rel="prefetch" href="/assets/js/360.439f5fae.js"><link rel="prefetch" href="/assets/js/361.39f782b4.js"><link rel="prefetch" href="/assets/js/362.106acf4c.js"><link rel="prefetch" href="/assets/js/363.562a4e1e.js"><link rel="prefetch" href="/assets/js/364.5940b069.js"><link rel="prefetch" href="/assets/js/365.e429c365.js"><link rel="prefetch" href="/assets/js/366.cc650df8.js"><link rel="prefetch" href="/assets/js/367.347592c9.js"><link rel="prefetch" href="/assets/js/368.d68ce88d.js"><link rel="prefetch" href="/assets/js/369.034e7f1e.js"><link rel="prefetch" href="/assets/js/37.9d026956.js"><link rel="prefetch" href="/assets/js/370.ac6fc7a5.js"><link rel="prefetch" href="/assets/js/371.e70219a6.js"><link rel="prefetch" href="/assets/js/372.c449fc49.js"><link rel="prefetch" href="/assets/js/373.f07bea72.js"><link rel="prefetch" href="/assets/js/374.8152408f.js"><link rel="prefetch" href="/assets/js/375.63c70dab.js"><link rel="prefetch" href="/assets/js/376.06de19db.js"><link rel="prefetch" href="/assets/js/377.2319ddb1.js"><link rel="prefetch" href="/assets/js/378.4821e23c.js"><link rel="prefetch" href="/assets/js/379.54a13769.js"><link rel="prefetch" href="/assets/js/38.23e83578.js"><link rel="prefetch" href="/assets/js/380.dac4cd46.js"><link rel="prefetch" href="/assets/js/381.8f83d1d7.js"><link rel="prefetch" href="/assets/js/382.e76e7d88.js"><link rel="prefetch" href="/assets/js/383.df731ee4.js"><link rel="prefetch" href="/assets/js/384.5093369e.js"><link rel="prefetch" href="/assets/js/385.ee576341.js"><link rel="prefetch" href="/assets/js/386.087a29a9.js"><link rel="prefetch" href="/assets/js/387.9f44d03b.js"><link rel="prefetch" href="/assets/js/388.a3f70992.js"><link rel="prefetch" href="/assets/js/389.df6e2ced.js"><link rel="prefetch" href="/assets/js/39.e9699d7f.js"><link rel="prefetch" href="/assets/js/390.c377efca.js"><link rel="prefetch" href="/assets/js/391.d7747385.js"><link rel="prefetch" href="/assets/js/392.bf8e8c1a.js"><link rel="prefetch" href="/assets/js/393.b4ed3be0.js"><link rel="prefetch" href="/assets/js/394.48eb505a.js"><link rel="prefetch" href="/assets/js/395.d9cd4812.js"><link rel="prefetch" href="/assets/js/396.b386a6b5.js"><link rel="prefetch" href="/assets/js/397.d19960fa.js"><link rel="prefetch" href="/assets/js/398.15f66e2a.js"><link rel="prefetch" href="/assets/js/399.cc4af83b.js"><link rel="prefetch" href="/assets/js/40.3a541653.js"><link rel="prefetch" href="/assets/js/400.d99e4b93.js"><link rel="prefetch" href="/assets/js/401.13fa06dd.js"><link rel="prefetch" href="/assets/js/402.3629b866.js"><link rel="prefetch" href="/assets/js/403.5826b040.js"><link rel="prefetch" href="/assets/js/404.d4b35549.js"><link rel="prefetch" href="/assets/js/405.9142a002.js"><link rel="prefetch" href="/assets/js/406.ba50e04d.js"><link rel="prefetch" href="/assets/js/407.b5271c6f.js"><link rel="prefetch" href="/assets/js/408.18baa241.js"><link rel="prefetch" href="/assets/js/409.6151d46b.js"><link rel="prefetch" href="/assets/js/41.b10ef41f.js"><link rel="prefetch" href="/assets/js/410.bb1fd058.js"><link rel="prefetch" href="/assets/js/411.9273fd47.js"><link rel="prefetch" href="/assets/js/412.d6b790c1.js"><link rel="prefetch" href="/assets/js/413.4c5a30bb.js"><link rel="prefetch" href="/assets/js/414.01aa0e0a.js"><link rel="prefetch" href="/assets/js/415.2633ad61.js"><link rel="prefetch" href="/assets/js/416.7a2263a9.js"><link rel="prefetch" href="/assets/js/417.98368241.js"><link rel="prefetch" href="/assets/js/418.ffeb9c9c.js"><link rel="prefetch" href="/assets/js/419.633f9efe.js"><link rel="prefetch" href="/assets/js/42.aa8b7c99.js"><link rel="prefetch" href="/assets/js/420.69868f4a.js"><link rel="prefetch" href="/assets/js/421.937d87cc.js"><link rel="prefetch" href="/assets/js/422.375fe09b.js"><link rel="prefetch" href="/assets/js/423.8d335fd6.js"><link rel="prefetch" href="/assets/js/424.d5b181d7.js"><link rel="prefetch" href="/assets/js/425.e06749ea.js"><link rel="prefetch" href="/assets/js/426.d7a23361.js"><link rel="prefetch" href="/assets/js/427.c26079c3.js"><link rel="prefetch" href="/assets/js/428.788e60b3.js"><link rel="prefetch" href="/assets/js/429.212c3091.js"><link rel="prefetch" href="/assets/js/43.bbf1f09a.js"><link rel="prefetch" href="/assets/js/430.e156b1fa.js"><link rel="prefetch" href="/assets/js/431.b41e44c6.js"><link rel="prefetch" href="/assets/js/432.7534e280.js"><link rel="prefetch" href="/assets/js/433.3d203e2b.js"><link rel="prefetch" href="/assets/js/434.41bb5350.js"><link rel="prefetch" href="/assets/js/435.a5c93fd3.js"><link rel="prefetch" href="/assets/js/436.60910866.js"><link rel="prefetch" href="/assets/js/437.7ae74f40.js"><link rel="prefetch" href="/assets/js/438.dc802af3.js"><link rel="prefetch" href="/assets/js/439.0de7c2a4.js"><link rel="prefetch" href="/assets/js/44.c0079627.js"><link rel="prefetch" href="/assets/js/440.43bc725f.js"><link rel="prefetch" href="/assets/js/441.1402dd2a.js"><link rel="prefetch" href="/assets/js/442.6106e1be.js"><link rel="prefetch" href="/assets/js/443.40909ac7.js"><link rel="prefetch" href="/assets/js/444.e506898d.js"><link rel="prefetch" href="/assets/js/445.8636f7a3.js"><link rel="prefetch" href="/assets/js/446.de915ed4.js"><link rel="prefetch" href="/assets/js/447.c7ac8e6e.js"><link rel="prefetch" href="/assets/js/448.9797a750.js"><link rel="prefetch" href="/assets/js/449.5d1f4748.js"><link rel="prefetch" href="/assets/js/45.2a09d581.js"><link rel="prefetch" href="/assets/js/450.42babefe.js"><link rel="prefetch" href="/assets/js/451.ee1b8ff8.js"><link rel="prefetch" href="/assets/js/452.7536e7c2.js"><link rel="prefetch" href="/assets/js/453.39a21d52.js"><link rel="prefetch" href="/assets/js/454.6511d1e1.js"><link rel="prefetch" href="/assets/js/455.2abb8ea0.js"><link rel="prefetch" href="/assets/js/456.5724d799.js"><link rel="prefetch" href="/assets/js/457.c32c0755.js"><link rel="prefetch" href="/assets/js/458.f67c539b.js"><link rel="prefetch" href="/assets/js/459.1634e8da.js"><link rel="prefetch" href="/assets/js/46.58b302e4.js"><link rel="prefetch" href="/assets/js/460.a22ac002.js"><link rel="prefetch" href="/assets/js/461.2c152148.js"><link rel="prefetch" href="/assets/js/462.14b038cf.js"><link rel="prefetch" href="/assets/js/463.dd0a3a00.js"><link rel="prefetch" href="/assets/js/464.f22ba288.js"><link rel="prefetch" href="/assets/js/465.9c187041.js"><link rel="prefetch" href="/assets/js/466.9957dd67.js"><link rel="prefetch" href="/assets/js/467.047041e8.js"><link rel="prefetch" href="/assets/js/468.425b6f20.js"><link rel="prefetch" href="/assets/js/469.2f70ecf7.js"><link rel="prefetch" href="/assets/js/47.987d79be.js"><link rel="prefetch" href="/assets/js/470.602b7d98.js"><link rel="prefetch" href="/assets/js/471.ddabe1b6.js"><link rel="prefetch" href="/assets/js/472.3a1ad521.js"><link rel="prefetch" href="/assets/js/473.2be352ab.js"><link rel="prefetch" href="/assets/js/474.e9c805de.js"><link rel="prefetch" href="/assets/js/475.93cab6cb.js"><link rel="prefetch" href="/assets/js/476.89384fa4.js"><link rel="prefetch" href="/assets/js/477.2b282ee8.js"><link rel="prefetch" href="/assets/js/478.27790491.js"><link rel="prefetch" href="/assets/js/479.2b728ba6.js"><link rel="prefetch" href="/assets/js/48.0e76d761.js"><link rel="prefetch" href="/assets/js/480.bd0beea9.js"><link rel="prefetch" href="/assets/js/481.004a0005.js"><link rel="prefetch" href="/assets/js/482.d9c6dc45.js"><link rel="prefetch" href="/assets/js/483.e7842361.js"><link rel="prefetch" href="/assets/js/484.702ac9a3.js"><link rel="prefetch" href="/assets/js/485.d38ba4c2.js"><link rel="prefetch" href="/assets/js/486.8a0cd211.js"><link rel="prefetch" href="/assets/js/487.18e243bb.js"><link rel="prefetch" href="/assets/js/488.cb0ad1bf.js"><link rel="prefetch" href="/assets/js/489.7c7adc5c.js"><link rel="prefetch" href="/assets/js/49.83e0619b.js"><link rel="prefetch" href="/assets/js/490.3f86a6a4.js"><link rel="prefetch" href="/assets/js/491.c1c90b4f.js"><link rel="prefetch" href="/assets/js/492.5658313d.js"><link rel="prefetch" href="/assets/js/493.9b953b18.js"><link rel="prefetch" href="/assets/js/494.80e3d4f4.js"><link rel="prefetch" href="/assets/js/495.66650a67.js"><link rel="prefetch" href="/assets/js/496.4e0d753b.js"><link rel="prefetch" href="/assets/js/497.1837b7c2.js"><link rel="prefetch" href="/assets/js/498.e2dcd450.js"><link rel="prefetch" href="/assets/js/499.4d5022f2.js"><link rel="prefetch" href="/assets/js/5.f343fd5d.js"><link rel="prefetch" href="/assets/js/50.6716fe91.js"><link rel="prefetch" href="/assets/js/500.10c0ee69.js"><link rel="prefetch" href="/assets/js/501.be3f9599.js"><link rel="prefetch" href="/assets/js/502.27844894.js"><link rel="prefetch" href="/assets/js/503.15f84a9b.js"><link rel="prefetch" href="/assets/js/504.60780a8e.js"><link rel="prefetch" href="/assets/js/505.6f9bed41.js"><link rel="prefetch" href="/assets/js/506.3e19b413.js"><link rel="prefetch" href="/assets/js/507.a12a02cb.js"><link rel="prefetch" href="/assets/js/508.b1384524.js"><link rel="prefetch" href="/assets/js/509.c74ef6c0.js"><link rel="prefetch" href="/assets/js/51.bc8d5aaf.js"><link rel="prefetch" href="/assets/js/510.266a6048.js"><link rel="prefetch" href="/assets/js/511.be98a2ef.js"><link rel="prefetch" href="/assets/js/512.e033e89e.js"><link rel="prefetch" href="/assets/js/513.837b9052.js"><link rel="prefetch" href="/assets/js/514.38271d19.js"><link rel="prefetch" href="/assets/js/515.c08327b5.js"><link rel="prefetch" href="/assets/js/516.3d573fdf.js"><link rel="prefetch" href="/assets/js/517.5406a8bd.js"><link rel="prefetch" href="/assets/js/518.543bea6f.js"><link rel="prefetch" href="/assets/js/519.e4967ce6.js"><link rel="prefetch" href="/assets/js/52.20603f07.js"><link rel="prefetch" href="/assets/js/520.0a863135.js"><link rel="prefetch" href="/assets/js/521.80c26149.js"><link rel="prefetch" href="/assets/js/522.5d0549ee.js"><link rel="prefetch" href="/assets/js/523.4b5d705c.js"><link rel="prefetch" href="/assets/js/524.24354cd8.js"><link rel="prefetch" href="/assets/js/525.d201b688.js"><link rel="prefetch" href="/assets/js/526.f405c35a.js"><link rel="prefetch" href="/assets/js/527.921d252f.js"><link rel="prefetch" href="/assets/js/528.cb45a5dd.js"><link rel="prefetch" href="/assets/js/529.aeec69e2.js"><link rel="prefetch" href="/assets/js/53.9604c447.js"><link rel="prefetch" href="/assets/js/530.7d5514c0.js"><link rel="prefetch" href="/assets/js/531.de381ab2.js"><link rel="prefetch" href="/assets/js/532.31b6e993.js"><link rel="prefetch" href="/assets/js/533.23335bff.js"><link rel="prefetch" href="/assets/js/534.131d260d.js"><link rel="prefetch" href="/assets/js/535.3057e7f2.js"><link rel="prefetch" href="/assets/js/536.1df4cc6e.js"><link rel="prefetch" href="/assets/js/537.c23a3391.js"><link rel="prefetch" href="/assets/js/538.ac3546d3.js"><link rel="prefetch" href="/assets/js/539.36137525.js"><link rel="prefetch" href="/assets/js/54.841e8e8f.js"><link rel="prefetch" href="/assets/js/540.f9171241.js"><link rel="prefetch" href="/assets/js/541.00a9732f.js"><link rel="prefetch" href="/assets/js/542.d981dcf7.js"><link rel="prefetch" href="/assets/js/543.0016cdef.js"><link rel="prefetch" href="/assets/js/544.b24fa17d.js"><link rel="prefetch" href="/assets/js/545.8adcd15c.js"><link rel="prefetch" href="/assets/js/546.189f10ef.js"><link rel="prefetch" href="/assets/js/547.d47175ac.js"><link rel="prefetch" href="/assets/js/548.67ed7a21.js"><link rel="prefetch" href="/assets/js/549.a72c957e.js"><link rel="prefetch" href="/assets/js/55.eccc64f8.js"><link rel="prefetch" href="/assets/js/550.c127415f.js"><link rel="prefetch" href="/assets/js/551.288648b2.js"><link rel="prefetch" href="/assets/js/552.5191109c.js"><link rel="prefetch" href="/assets/js/553.a0417c79.js"><link rel="prefetch" href="/assets/js/554.05224c83.js"><link rel="prefetch" href="/assets/js/555.d95f24bd.js"><link rel="prefetch" href="/assets/js/556.42a17364.js"><link rel="prefetch" href="/assets/js/557.a066d457.js"><link rel="prefetch" href="/assets/js/558.1f4641c3.js"><link rel="prefetch" href="/assets/js/559.f85fd85a.js"><link rel="prefetch" href="/assets/js/56.9ede6cf7.js"><link rel="prefetch" href="/assets/js/560.c486ead6.js"><link rel="prefetch" href="/assets/js/561.5654ef71.js"><link rel="prefetch" href="/assets/js/562.8ac06965.js"><link rel="prefetch" href="/assets/js/563.209407dd.js"><link rel="prefetch" href="/assets/js/564.4da5848b.js"><link rel="prefetch" href="/assets/js/565.0ea0c2cb.js"><link rel="prefetch" href="/assets/js/566.fbb62b05.js"><link rel="prefetch" href="/assets/js/567.0454bee2.js"><link rel="prefetch" href="/assets/js/568.5aad57f8.js"><link rel="prefetch" href="/assets/js/569.b4b199ad.js"><link rel="prefetch" href="/assets/js/57.2e9b38e9.js"><link rel="prefetch" href="/assets/js/570.890f1d05.js"><link rel="prefetch" href="/assets/js/571.56e5f721.js"><link rel="prefetch" href="/assets/js/572.fa3418f1.js"><link rel="prefetch" href="/assets/js/573.224ada77.js"><link rel="prefetch" href="/assets/js/574.4cc85330.js"><link rel="prefetch" href="/assets/js/575.61a17f5e.js"><link rel="prefetch" href="/assets/js/576.0ec5efb8.js"><link rel="prefetch" href="/assets/js/577.6bc915dd.js"><link rel="prefetch" href="/assets/js/578.fd4e39e7.js"><link rel="prefetch" href="/assets/js/579.0238c950.js"><link rel="prefetch" href="/assets/js/58.f28ad3cc.js"><link rel="prefetch" href="/assets/js/580.a08c6c02.js"><link rel="prefetch" href="/assets/js/581.392f9c6f.js"><link rel="prefetch" href="/assets/js/582.2f59e9f2.js"><link rel="prefetch" href="/assets/js/583.2097fe85.js"><link rel="prefetch" href="/assets/js/584.f0d8c622.js"><link rel="prefetch" href="/assets/js/585.85fab1f2.js"><link rel="prefetch" href="/assets/js/586.c359098c.js"><link rel="prefetch" href="/assets/js/587.1dff90c3.js"><link rel="prefetch" href="/assets/js/588.6afc16eb.js"><link rel="prefetch" href="/assets/js/589.4337cfee.js"><link rel="prefetch" href="/assets/js/590.f969cc18.js"><link rel="prefetch" href="/assets/js/591.dfceaca2.js"><link rel="prefetch" href="/assets/js/592.b670f7b8.js"><link rel="prefetch" href="/assets/js/593.85ff3e7e.js"><link rel="prefetch" href="/assets/js/594.87d3c73b.js"><link rel="prefetch" href="/assets/js/595.18f2a1df.js"><link rel="prefetch" href="/assets/js/596.adb07b39.js"><link rel="prefetch" href="/assets/js/597.4bfdae44.js"><link rel="prefetch" href="/assets/js/598.a4f73bf5.js"><link rel="prefetch" href="/assets/js/599.5b85b7f2.js"><link rel="prefetch" href="/assets/js/6.6f5ae702.js"><link rel="prefetch" href="/assets/js/60.3095e21a.js"><link rel="prefetch" href="/assets/js/600.98cef029.js"><link rel="prefetch" href="/assets/js/601.34cfecd2.js"><link rel="prefetch" href="/assets/js/602.afaf2e1f.js"><link rel="prefetch" href="/assets/js/603.5f081041.js"><link rel="prefetch" href="/assets/js/604.a55dc3e4.js"><link rel="prefetch" href="/assets/js/605.cc600bca.js"><link rel="prefetch" href="/assets/js/606.9e0874e1.js"><link rel="prefetch" href="/assets/js/607.bd0a2835.js"><link rel="prefetch" href="/assets/js/608.e3c0bb6d.js"><link rel="prefetch" href="/assets/js/609.968adfbe.js"><link rel="prefetch" href="/assets/js/61.cd58c0e2.js"><link rel="prefetch" href="/assets/js/610.6ddb82e2.js"><link rel="prefetch" href="/assets/js/611.f6573e33.js"><link rel="prefetch" href="/assets/js/612.cd703232.js"><link rel="prefetch" href="/assets/js/613.5ae48097.js"><link rel="prefetch" href="/assets/js/614.c9fc5628.js"><link rel="prefetch" href="/assets/js/615.5f3c1162.js"><link rel="prefetch" href="/assets/js/616.3efeed17.js"><link rel="prefetch" href="/assets/js/617.25dec672.js"><link rel="prefetch" href="/assets/js/618.b53f21b6.js"><link rel="prefetch" href="/assets/js/619.e0c2de74.js"><link rel="prefetch" href="/assets/js/62.aa4d202d.js"><link rel="prefetch" href="/assets/js/620.88136c6a.js"><link rel="prefetch" href="/assets/js/621.494122df.js"><link rel="prefetch" href="/assets/js/622.e2a6e4bd.js"><link rel="prefetch" href="/assets/js/623.20a56d61.js"><link rel="prefetch" href="/assets/js/624.602dd933.js"><link rel="prefetch" href="/assets/js/625.70f44f60.js"><link rel="prefetch" href="/assets/js/626.11524978.js"><link rel="prefetch" href="/assets/js/627.b3badb72.js"><link rel="prefetch" href="/assets/js/628.e613665e.js"><link rel="prefetch" href="/assets/js/629.20e73b43.js"><link rel="prefetch" href="/assets/js/63.f7cd40f4.js"><link rel="prefetch" href="/assets/js/630.6099312f.js"><link rel="prefetch" href="/assets/js/631.669bcda0.js"><link rel="prefetch" href="/assets/js/632.d33f5ec9.js"><link rel="prefetch" href="/assets/js/633.211456ee.js"><link rel="prefetch" href="/assets/js/634.ea9d07ae.js"><link rel="prefetch" href="/assets/js/635.f22368f1.js"><link rel="prefetch" href="/assets/js/636.ebe249f7.js"><link rel="prefetch" href="/assets/js/637.7b645ab3.js"><link rel="prefetch" href="/assets/js/638.4565c395.js"><link rel="prefetch" href="/assets/js/639.c5144f9c.js"><link rel="prefetch" href="/assets/js/64.8cd3aa43.js"><link rel="prefetch" href="/assets/js/640.2dc2eba9.js"><link rel="prefetch" href="/assets/js/641.70155ce7.js"><link rel="prefetch" href="/assets/js/642.c55f5ca8.js"><link rel="prefetch" href="/assets/js/643.69a5b8e5.js"><link rel="prefetch" href="/assets/js/644.84431935.js"><link rel="prefetch" href="/assets/js/645.5119ebc2.js"><link rel="prefetch" href="/assets/js/646.506fc745.js"><link rel="prefetch" href="/assets/js/647.e5f03652.js"><link rel="prefetch" href="/assets/js/648.47ae0cc5.js"><link rel="prefetch" href="/assets/js/649.b3a67529.js"><link rel="prefetch" href="/assets/js/65.14b3da5d.js"><link rel="prefetch" href="/assets/js/650.89765bb0.js"><link rel="prefetch" href="/assets/js/651.19b73cf8.js"><link rel="prefetch" href="/assets/js/652.4436725f.js"><link rel="prefetch" href="/assets/js/653.391168ff.js"><link rel="prefetch" href="/assets/js/654.8b449d07.js"><link rel="prefetch" href="/assets/js/655.27051c8c.js"><link rel="prefetch" href="/assets/js/656.7adaae31.js"><link rel="prefetch" href="/assets/js/657.4fee46d2.js"><link rel="prefetch" href="/assets/js/658.0243a6e8.js"><link rel="prefetch" href="/assets/js/659.f69398bc.js"><link rel="prefetch" href="/assets/js/66.899fc260.js"><link rel="prefetch" href="/assets/js/660.5e51ab7c.js"><link rel="prefetch" href="/assets/js/661.980d3d5a.js"><link rel="prefetch" href="/assets/js/662.79643730.js"><link rel="prefetch" href="/assets/js/663.d030bd1d.js"><link rel="prefetch" href="/assets/js/664.32b3c0e8.js"><link rel="prefetch" href="/assets/js/665.384c456b.js"><link rel="prefetch" href="/assets/js/666.2672eb36.js"><link rel="prefetch" href="/assets/js/667.2ca85ff9.js"><link rel="prefetch" href="/assets/js/668.b80ef3b4.js"><link rel="prefetch" href="/assets/js/669.41f08cb1.js"><link rel="prefetch" href="/assets/js/67.c0e799e4.js"><link rel="prefetch" href="/assets/js/670.48512f45.js"><link rel="prefetch" href="/assets/js/671.93e1cdd9.js"><link rel="prefetch" href="/assets/js/672.aa2a7e31.js"><link rel="prefetch" href="/assets/js/673.b19ed80d.js"><link rel="prefetch" href="/assets/js/674.0337bf32.js"><link rel="prefetch" href="/assets/js/675.88a9d569.js"><link rel="prefetch" href="/assets/js/676.7fd2de1c.js"><link rel="prefetch" href="/assets/js/677.1356b477.js"><link rel="prefetch" href="/assets/js/678.d99fd658.js"><link rel="prefetch" href="/assets/js/679.a2e40bc7.js"><link rel="prefetch" href="/assets/js/68.2e72dacb.js"><link rel="prefetch" href="/assets/js/680.58e5d76e.js"><link rel="prefetch" href="/assets/js/681.2e66d773.js"><link rel="prefetch" href="/assets/js/682.42526013.js"><link rel="prefetch" href="/assets/js/683.447d4972.js"><link rel="prefetch" href="/assets/js/684.19beb22a.js"><link rel="prefetch" href="/assets/js/685.cd3fd615.js"><link rel="prefetch" href="/assets/js/686.c6200f3f.js"><link rel="prefetch" href="/assets/js/687.3d6cf8bb.js"><link rel="prefetch" href="/assets/js/688.e9ddd041.js"><link rel="prefetch" href="/assets/js/689.74bb6414.js"><link rel="prefetch" href="/assets/js/69.d29a7787.js"><link rel="prefetch" href="/assets/js/690.82b51acd.js"><link rel="prefetch" href="/assets/js/691.a6edc5c3.js"><link rel="prefetch" href="/assets/js/692.c5fd2fa7.js"><link rel="prefetch" href="/assets/js/693.0c0b8126.js"><link rel="prefetch" href="/assets/js/694.551ae4d1.js"><link rel="prefetch" href="/assets/js/695.2801a2f2.js"><link rel="prefetch" href="/assets/js/696.8723006b.js"><link rel="prefetch" href="/assets/js/697.275e71c7.js"><link rel="prefetch" href="/assets/js/698.431e2bfb.js"><link rel="prefetch" href="/assets/js/699.c82907d3.js"><link rel="prefetch" href="/assets/js/7.c8b0ee6b.js"><link rel="prefetch" href="/assets/js/70.53b18677.js"><link rel="prefetch" href="/assets/js/700.9faf8917.js"><link rel="prefetch" href="/assets/js/701.5ce77f04.js"><link rel="prefetch" href="/assets/js/702.488262eb.js"><link rel="prefetch" href="/assets/js/703.8f79363d.js"><link rel="prefetch" href="/assets/js/704.a4cfe8cb.js"><link rel="prefetch" href="/assets/js/705.4f1759eb.js"><link rel="prefetch" href="/assets/js/706.baf03b10.js"><link rel="prefetch" href="/assets/js/707.48c01840.js"><link rel="prefetch" href="/assets/js/708.b3cda177.js"><link rel="prefetch" href="/assets/js/709.260cc3a8.js"><link rel="prefetch" href="/assets/js/71.b44506bc.js"><link rel="prefetch" href="/assets/js/710.e4fa6646.js"><link rel="prefetch" href="/assets/js/711.7816aba5.js"><link rel="prefetch" href="/assets/js/712.14939ffd.js"><link rel="prefetch" href="/assets/js/72.9793c1ce.js"><link rel="prefetch" href="/assets/js/73.b4d37c7e.js"><link rel="prefetch" href="/assets/js/74.b816cbc7.js"><link rel="prefetch" href="/assets/js/75.9f45a274.js"><link rel="prefetch" href="/assets/js/76.4921e235.js"><link rel="prefetch" href="/assets/js/77.f9258c97.js"><link rel="prefetch" href="/assets/js/78.55656c0f.js"><link rel="prefetch" href="/assets/js/79.b5784c72.js"><link rel="prefetch" href="/assets/js/8.44118d7c.js"><link rel="prefetch" href="/assets/js/80.98240933.js"><link rel="prefetch" href="/assets/js/81.5421fa90.js"><link rel="prefetch" href="/assets/js/82.72a10ccf.js"><link rel="prefetch" href="/assets/js/83.abdca93e.js"><link rel="prefetch" href="/assets/js/84.5d0190e3.js"><link rel="prefetch" href="/assets/js/85.5d2a1647.js"><link rel="prefetch" href="/assets/js/86.5aea5730.js"><link rel="prefetch" href="/assets/js/87.bfe2bb57.js"><link rel="prefetch" href="/assets/js/88.4097611c.js"><link rel="prefetch" href="/assets/js/89.e5a98da0.js"><link rel="prefetch" href="/assets/js/9.612b54fd.js"><link rel="prefetch" href="/assets/js/90.5564a69b.js"><link rel="prefetch" href="/assets/js/91.ff219511.js"><link rel="prefetch" href="/assets/js/92.8191f073.js"><link rel="prefetch" href="/assets/js/93.4b6ecb16.js"><link rel="prefetch" href="/assets/js/94.fd999a73.js"><link rel="prefetch" href="/assets/js/95.c96c310d.js"><link rel="prefetch" href="/assets/js/96.2eb0ab2f.js"><link rel="prefetch" href="/assets/js/97.4c8c6fba.js"><link rel="prefetch" href="/assets/js/98.f9ef7bdb.js"><link rel="prefetch" href="/assets/js/99.513483d0.js"><link rel="prefetch" href="/assets/js/vendors~docsearch.49ad9c45.js">
    <link rel="stylesheet" href="/assets/css/0.styles.af3770e9.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/en/" class="home-link router-link-active"><img src="/images/icons/spring-logo.svg" alt="Spring Docs" class="logo"> <span class="site-name can-hide">Spring Docs</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/en/spring/why-spring.html" class="nav-link">
  Spring
</a></div><div class="nav-item"><a href="/en/spring-boot/getting-help.html" class="nav-link">
  Spring Boot
</a></div><div class="nav-item"><a href="/en/spring-cloud/documentation-overview.html" class="nav-link">
  Spring Cloud
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Others" class="dropdown-title"><span class="title">more</span> <span class="arrow down"></span></button> <button type="button" aria-label="Others" class="mobile-dropdown-title"><span class="title">more</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/spring-framework/overview.html" class="nav-link">
  Spring Framework
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-data/spring-data.html" class="nav-link">
  Spring Data
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-cloud-data-flow/spring-cloud-dataflow.html" class="nav-link">
  Spring Cloud Data Flow
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-security/overview.html" class="nav-link">
  Spring Security
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-for-graphql/spring-graphql.html" class="nav-link">
  Spring for GraphQL
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-session/_index.html" class="nav-link">
  Spring Session
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-integration/preface.html" class="nav-link">
  Spring Integration
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-hateoas/spring-hateoas.html" class="nav-link">
  Spring HATEOAS
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-rest-docs/spring-restdocs.html" class="nav-link">
  Spring REST Docs
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-batch/spring-batch-intro.html" class="nav-link">
  Spring Batch
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-amqp/spring-amqp.html" class="nav-link">
  Spring AMQP
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-credhub/spring-credhub.html" class="nav-link">
  Spring CredHub
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-flo/spring-flo.html" class="nav-link">
  Spring Flo
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-for-apache-kafka/spring-kafka.html" class="nav-link">
  Spring for Apache Kafka
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-ldap/spring-ldap.html" class="nav-link">
  Spring LDAP
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-shell/spring-shell.html" class="nav-link">
  Spring Shell
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-statemachine/spring-statemachine.html" class="nav-link">
  Spring Statemachine
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-vault/spring-vault.html" class="nav-link">
  Spring Vault
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-web-flow/preface.html" class="nav-link">
  Spring Web Flow
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-web-services/spring-web-service.html" class="nav-link">
  Spring Web Services
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Language</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Language</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/spring-boot/web.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
  English
</a></li><li class="dropdown-item"><!----> <a href="/spring-boot/web.html" class="nav-link">
  简体中文
</a></li></ul></div></div> <a href="https://gitcode.net/dev-cloud/spring-docs" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitCode
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/en/spring/why-spring.html" class="nav-link">
  Spring
</a></div><div class="nav-item"><a href="/en/spring-boot/getting-help.html" class="nav-link">
  Spring Boot
</a></div><div class="nav-item"><a href="/en/spring-cloud/documentation-overview.html" class="nav-link">
  Spring Cloud
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Others" class="dropdown-title"><span class="title">more</span> <span class="arrow down"></span></button> <button type="button" aria-label="Others" class="mobile-dropdown-title"><span class="title">more</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/spring-framework/overview.html" class="nav-link">
  Spring Framework
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-data/spring-data.html" class="nav-link">
  Spring Data
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-cloud-data-flow/spring-cloud-dataflow.html" class="nav-link">
  Spring Cloud Data Flow
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-security/overview.html" class="nav-link">
  Spring Security
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-for-graphql/spring-graphql.html" class="nav-link">
  Spring for GraphQL
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-session/_index.html" class="nav-link">
  Spring Session
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-integration/preface.html" class="nav-link">
  Spring Integration
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-hateoas/spring-hateoas.html" class="nav-link">
  Spring HATEOAS
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-rest-docs/spring-restdocs.html" class="nav-link">
  Spring REST Docs
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-batch/spring-batch-intro.html" class="nav-link">
  Spring Batch
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-amqp/spring-amqp.html" class="nav-link">
  Spring AMQP
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-credhub/spring-credhub.html" class="nav-link">
  Spring CredHub
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-flo/spring-flo.html" class="nav-link">
  Spring Flo
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-for-apache-kafka/spring-kafka.html" class="nav-link">
  Spring for Apache Kafka
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-ldap/spring-ldap.html" class="nav-link">
  Spring LDAP
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-shell/spring-shell.html" class="nav-link">
  Spring Shell
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-statemachine/spring-statemachine.html" class="nav-link">
  Spring Statemachine
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-vault/spring-vault.html" class="nav-link">
  Spring Vault
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-web-flow/preface.html" class="nav-link">
  Spring Web Flow
</a></li><li class="dropdown-item"><!----> <a href="/en/spring-web-services/spring-web-service.html" class="nav-link">
  Spring Web Services
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Language</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Language</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/spring-boot/web.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
  English
</a></li><li class="dropdown-item"><!----> <a href="/spring-boot/web.html" class="nav-link">
  简体中文
</a></li></ul></div></div> <a href="https://gitcode.net/dev-cloud/spring-docs" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitCode
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Spring Boot</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/en/spring-boot/getting-help.html" class="sidebar-link">Getting Help</a></li><li><a href="/en/spring-boot/documentation.html" class="sidebar-link">Documentation Overview</a></li><li><a href="/en/spring-boot/getting-started.html" class="sidebar-link">Getting Started</a></li><li><a href="/en/spring-boot/upgrading.html" class="sidebar-link">Upgrading Spring Boot</a></li><li><a href="/en/spring-boot/using.html" class="sidebar-link">Developing with Spring Boot</a></li><li><a href="/en/spring-boot/features.html" class="sidebar-link">Core Features</a></li><li><a href="/en/spring-boot/web.html" aria-current="page" class="active sidebar-link">Web</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_1-servlet-web-applications" class="sidebar-link">1. Servlet Web Applications</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_1-1-the-spring-web-mvc-framework" class="sidebar-link">1.1. The “Spring Web MVC Framework”</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_1-2-jax-rs-and-jersey" class="sidebar-link">1.2. JAX-RS and Jersey</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_1-3-embedded-servlet-container-support" class="sidebar-link">1.3. Embedded Servlet Container Support</a></li></ul></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_2-reactive-web-applications" class="sidebar-link">2. Reactive Web Applications</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_2-1-the-spring-webflux-framework" class="sidebar-link">2.1. The “Spring WebFlux Framework”</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_2-2-embedded-reactive-server-support" class="sidebar-link">2.2. Embedded Reactive Server Support</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_2-3-reactive-server-resources-configuration" class="sidebar-link">2.3. Reactive Server Resources Configuration</a></li></ul></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_3-graceful-shutdown" class="sidebar-link">3. Graceful Shutdown</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_4-spring-security" class="sidebar-link">4. Spring Security</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_4-1-mvc-security" class="sidebar-link">4.1. MVC Security</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_4-2-webflux-security" class="sidebar-link">4.2. WebFlux Security</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_4-3-oauth2" class="sidebar-link">4.3. OAuth2</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_4-4-saml-2-0" class="sidebar-link">4.4. SAML 2.0</a></li></ul></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_5-spring-session" class="sidebar-link">5. Spring Session</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_6-spring-hateoas" class="sidebar-link">6. Spring HATEOAS</a></li><li class="sidebar-sub-header"><a href="/en/spring-boot/web.html#_7-what-to-read-next" class="sidebar-link">7. What to Read Next</a></li></ul></li><li><a href="/en/spring-boot/data.html" class="sidebar-link">Data</a></li><li><a href="/en/spring-boot/io.html" class="sidebar-link">IO</a></li><li><a href="/en/spring-boot/messaging.html" class="sidebar-link">Messaging</a></li><li><a href="/en/spring-boot/container-images.html" class="sidebar-link">Container Images</a></li><li><a href="/en/spring-boot/actuator.html" class="sidebar-link">Production-ready Features</a></li><li><a href="/en/spring-boot/deployment.html" class="sidebar-link">Deploying Spring Boot Applications</a></li><li><a href="/en/spring-boot/cli.html" class="sidebar-link">Spring Boot CLI</a></li><li><a href="/en/spring-boot/build-tool-plugins.html" class="sidebar-link">Build Tool Plugins</a></li><li><a href="/en/spring-boot/howto.html" class="sidebar-link">“How-to” Guides</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="web"><a href="#web" class="header-anchor">#</a> Web</h1> <p>Spring Boot is well suited for web application development.
You can create a self-contained HTTP server by using embedded Tomcat, Jetty, Undertow, or Netty.
Most web applications use the <code>spring-boot-starter-web</code> module to get up and running quickly.
You can also choose to build reactive web applications by using the <code>spring-boot-starter-webflux</code> module.</p> <p>If you have not yet developed a Spring Boot web application, you can follow the &quot;Hello World!&quot; example in the <em><a href="/en/spring-boot/getting-started.html#getting-started.first-application">Getting started</a></em> section.</p> <h2 id="_1-servlet-web-applications"><a href="#_1-servlet-web-applications" class="header-anchor">#</a> 1. Servlet Web Applications</h2> <p>If you want to build servlet-based web applications, you can take advantage of Spring Boot’s auto-configuration for Spring MVC or Jersey.</p> <h3 id="_1-1-the-spring-web-mvc-framework"><a href="#_1-1-the-spring-web-mvc-framework" class="header-anchor">#</a> 1.1. The “Spring Web MVC Framework”</h3> <p>The <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc" target="_blank" rel="noopener noreferrer">Spring Web MVC framework<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> (often referred to as “Spring MVC”) is a rich “model view controller” web framework.
Spring MVC lets you create special <code>@Controller</code> or <code>@RestController</code> beans to handle incoming HTTP requests.
Methods in your controller are mapped to HTTP by using <code>@RequestMapping</code> annotations.</p> <p>The following code shows a typical <code>@RestController</code> that serves JSON data:</p> <div class="language- extra-class"><pre class="language-text"><code>import java.util.List;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(&quot;/users&quot;)
public class MyRestController {

    private final UserRepository userRepository;

    private final CustomerRepository customerRepository;

    public MyRestController(UserRepository userRepository, CustomerRepository customerRepository) {
        this.userRepository = userRepository;
        this.customerRepository = customerRepository;
    }

    @GetMapping(&quot;/{user}&quot;)
    public User getUser(@PathVariable Long userId) {
        return this.userRepository.findById(userId).get();
    }

    @GetMapping(&quot;/{user}/customers&quot;)
    public List&lt;Customer&gt; getUserCustomers(@PathVariable Long userId) {
        return this.userRepository.findById(userId).map(this.customerRepository::findByUser).get();
    }

    @DeleteMapping(&quot;/{user}&quot;)
    public void deleteUser(@PathVariable Long userId) {
        this.userRepository.deleteById(userId);
    }

}

</code></pre></div><p>“WebMvc.fn”, the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.servlet.function.RequestPredicate;
import org.springframework.web.servlet.function.RouterFunction;
import org.springframework.web.servlet.function.ServerResponse;

import static org.springframework.web.servlet.function.RequestPredicates.accept;
import static org.springframework.web.servlet.function.RouterFunctions.route;

@Configuration(proxyBeanMethods = false)
public class MyRoutingConfiguration {

    private static final RequestPredicate ACCEPT_JSON = accept(MediaType.APPLICATION_JSON);

    @Bean
    public RouterFunction&lt;ServerResponse&gt; routerFunction(MyUserHandler userHandler) {
        return route()
                .GET(&quot;/{user}&quot;, ACCEPT_JSON, userHandler::getUser)
                .GET(&quot;/{user}/customers&quot;, ACCEPT_JSON, userHandler::getUserCustomers)
                .DELETE(&quot;/{user}&quot;, ACCEPT_JSON, userHandler::deleteUser)
                .build();
    }

}

</code></pre></div><div class="language- extra-class"><pre class="language-text"><code>import org.springframework.stereotype.Component;
import org.springframework.web.servlet.function.ServerRequest;
import org.springframework.web.servlet.function.ServerResponse;

@Component
public class MyUserHandler {

    public ServerResponse getUser(ServerRequest request) {
        ...
        return ServerResponse.ok().build();
    }

    public ServerResponse getUserCustomers(ServerRequest request) {
        ...
        return ServerResponse.ok().build();
    }

    public ServerResponse deleteUser(ServerRequest request) {
        ...
        return ServerResponse.ok().build();
    }

}

</code></pre></div><p>Spring MVC is part of the core Spring Framework, and detailed information is available in the <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc" target="_blank" rel="noopener noreferrer">reference documentation<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.
There are also several guides that cover Spring MVC available at <a href="https://spring.io/guides" target="_blank" rel="noopener noreferrer">spring.io/guides<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <table><thead><tr><th></th> <th>You can define as many <code>RouterFunction</code> beans as you like to modularize the definition of the router.<br>Beans can be ordered if you need to apply a precedence.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-1-1-spring-mvc-auto-configuration"><a href="#_1-1-1-spring-mvc-auto-configuration" class="header-anchor">#</a> 1.1.1. Spring MVC Auto-configuration</h4> <p>Spring Boot provides auto-configuration for Spring MVC that works well with most applications.</p> <p>The auto-configuration adds the following features on top of Spring’s defaults:</p> <ul><li><p>Inclusion of <code>ContentNegotiatingViewResolver</code> and <code>BeanNameViewResolver</code> beans.</p></li> <li><p>Support for serving static resources, including support for WebJars (covered <a href="/en/spring-boot/features.html#web.servlet.spring-mvc.static-content">later in this document</a>).</p></li> <li><p>Automatic registration of <code>Converter</code>, <code>GenericConverter</code>, and <code>Formatter</code> beans.</p></li> <li><p>Support for <code>HttpMessageConverters</code> (covered <a href="/en/spring-boot/features.html#web.servlet.spring-mvc.message-converters">later in this document</a>).</p></li> <li><p>Automatic registration of <code>MessageCodesResolver</code> (covered <a href="/en/spring-boot/features.html#web.servlet.spring-mvc.message-codes">later in this document</a>).</p></li> <li><p>Static <code>index.html</code> support.</p></li> <li><p>Automatic use of a <code>ConfigurableWebBindingInitializer</code> bean (covered <a href="/en/spring-boot/features.html#web.servlet.spring-mvc.binding-initializer">later in this document</a>).</p></li></ul> <p>If you want to keep those Spring Boot MVC customizations and make more <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc" target="_blank" rel="noopener noreferrer">MVC customizations<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> (interceptors, formatters, view controllers, and other features), you can add your own <code>@Configuration</code> class of type <code>WebMvcConfigurer</code> but <strong>without</strong> <code>@EnableWebMvc</code>.</p> <p>If you want to provide custom instances of <code>RequestMappingHandlerMapping</code>, <code>RequestMappingHandlerAdapter</code>, or <code>ExceptionHandlerExceptionResolver</code>, and still keep the Spring Boot MVC customizations, you can declare a bean of type <code>WebMvcRegistrations</code> and use it to provide custom instances of those components.</p> <p>If you want to take complete control of Spring MVC, you can add your own <code>@Configuration</code> annotated with <code>@EnableWebMvc</code>, or alternatively add your own <code>@Configuration</code>-annotated <code>DelegatingWebMvcConfiguration</code> as described in the Javadoc of <code>@EnableWebMvc</code>.</p> <table><thead><tr><th></th> <th>Spring MVC uses a different <code>ConversionService</code> to the one used to convert values from your <code>application.properties</code> or <code>application.yaml</code> file.<br>It means that <code>Period</code>, <code>Duration</code> and <code>DataSize</code> converters are not available and that <code>@DurationUnit</code> and <code>@DataSizeUnit</code> annotations will be ignored.<br><br>If you want to customize the <code>ConversionService</code> used by Spring MVC, you can provide a <code>WebMvcConfigurer</code> bean with an <code>addFormatters</code> method.<br>From this method you can register any converter that you like, or you can delegate to the static methods available on <code>ApplicationConversionService</code>.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-1-2-httpmessageconverters"><a href="#_1-1-2-httpmessageconverters" class="header-anchor">#</a> 1.1.2. HttpMessageConverters</h4> <p>Spring MVC uses the <code>HttpMessageConverter</code> interface to convert HTTP requests and responses.
Sensible defaults are included out of the box.
For example, objects can be automatically converted to JSON (by using the Jackson library) or XML (by using the Jackson XML extension, if available, or by using JAXB if the Jackson XML extension is not available).
By default, strings are encoded in <code>UTF-8</code>.</p> <p>If you need to add or customize converters, you can use Spring Boot’s <code>HttpMessageConverters</code> class, as shown in the following listing:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;

@Configuration(proxyBeanMethods = false)
public class MyHttpMessageConvertersConfiguration {

    @Bean
    public HttpMessageConverters customConverters() {
        HttpMessageConverter&lt;?&gt; additional = new AdditionalHttpMessageConverter();
        HttpMessageConverter&lt;?&gt; another = new AnotherHttpMessageConverter();
        return new HttpMessageConverters(additional, another);
    }

}

</code></pre></div><p>Any <code>HttpMessageConverter</code> bean that is present in the context is added to the list of converters.
You can also override default converters in the same way.</p> <h4 id="_1-1-3-custom-json-serializers-and-deserializers"><a href="#_1-1-3-custom-json-serializers-and-deserializers" class="header-anchor">#</a> 1.1.3. Custom JSON Serializers and Deserializers</h4> <p>If you use Jackson to serialize and deserialize JSON data, you might want to write your own <code>JsonSerializer</code> and <code>JsonDeserializer</code> classes.
Custom serializers are usually <a href="https://github.com/FasterXML/jackson-docs/wiki/JacksonHowToCustomSerializers" target="_blank" rel="noopener noreferrer">registered with Jackson through a module<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>, but Spring Boot provides an alternative <code>@JsonComponent</code> annotation that makes it easier to directly register Spring Beans.</p> <p>You can use the <code>@JsonComponent</code> annotation directly on <code>JsonSerializer</code>, <code>JsonDeserializer</code> or <code>KeyDeserializer</code> implementations.
You can also use it on classes that contain serializers/deserializers as inner classes, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import org.springframework.boot.jackson.JsonComponent;

@JsonComponent
public class MyJsonComponent {

    public static class Serializer extends JsonSerializer&lt;MyObject&gt; {

        @Override
        public void serialize(MyObject value, JsonGenerator jgen, SerializerProvider serializers) throws IOException {
            jgen.writeStringField(&quot;name&quot;, value.getName());
            jgen.writeNumberField(&quot;age&quot;, value.getAge());
        }

    }

    public static class Deserializer extends JsonDeserializer&lt;MyObject&gt; {

        @Override
        public MyObject deserialize(JsonParser jsonParser, DeserializationContext ctxt)
                throws IOException, JsonProcessingException {
            ObjectCodec codec = jsonParser.getCodec();
            JsonNode tree = codec.readTree(jsonParser);
            String name = tree.get(&quot;name&quot;).textValue();
            int age = tree.get(&quot;age&quot;).intValue();
            return new MyObject(name, age);
        }

    }

}

</code></pre></div><p>All <code>@JsonComponent</code> beans in the <code>ApplicationContext</code> are automatically registered with Jackson.
Because <code>@JsonComponent</code> is meta-annotated with <code>@Component</code>, the usual component-scanning rules apply.</p> <p>Spring Boot also provides <a href="https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectSerializer.java" target="_blank" rel="noopener noreferrer"><code>JsonObjectSerializer</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> and <a href="https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectDeserializer.java" target="_blank" rel="noopener noreferrer"><code>JsonObjectDeserializer</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> base classes that provide useful alternatives to the standard Jackson versions when serializing objects.
See <a href="https://docs.spring.io/spring-boot/docs/2.6.4/api/org/springframework/boot/jackson/JsonObjectSerializer.html" target="_blank" rel="noopener noreferrer"><code>JsonObjectSerializer</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> and <a href="https://docs.spring.io/spring-boot/docs/2.6.4/api/org/springframework/boot/jackson/JsonObjectDeserializer.html" target="_blank" rel="noopener noreferrer"><code>JsonObjectDeserializer</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> in the Javadoc for details.</p> <p>The example above can be rewritten to use <code>JsonObjectSerializer</code>/<code>JsonObjectDeserializer</code> as follows:</p> <div class="language- extra-class"><pre class="language-text"><code>import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.SerializerProvider;

import org.springframework.boot.jackson.JsonComponent;
import org.springframework.boot.jackson.JsonObjectDeserializer;
import org.springframework.boot.jackson.JsonObjectSerializer;

@JsonComponent
public class MyJsonComponent {

    public static class Serializer extends JsonObjectSerializer&lt;MyObject&gt; {

        @Override
        protected void serializeObject(MyObject value, JsonGenerator jgen, SerializerProvider provider)
                throws IOException {
            jgen.writeStringField(&quot;name&quot;, value.getName());
            jgen.writeNumberField(&quot;age&quot;, value.getAge());
        }

    }

    public static class Deserializer extends JsonObjectDeserializer&lt;MyObject&gt; {

        @Override
        protected MyObject deserializeObject(JsonParser jsonParser, DeserializationContext context, ObjectCodec codec,
                JsonNode tree) throws IOException {
            String name = nullSafeValue(tree.get(&quot;name&quot;), String.class);
            int age = nullSafeValue(tree.get(&quot;age&quot;), Integer.class);
            return new MyObject(name, age);
        }

    }

}

</code></pre></div><h4 id="_1-1-4-messagecodesresolver"><a href="#_1-1-4-messagecodesresolver" class="header-anchor">#</a> 1.1.4. MessageCodesResolver</h4> <p>Spring MVC has a strategy for generating error codes for rendering error messages from binding errors: <code>MessageCodesResolver</code>.
If you set the <code>spring.mvc.message-codes-resolver-format</code> property <code>PREFIX_ERROR_CODE</code> or <code>POSTFIX_ERROR_CODE</code>, Spring Boot creates one for you (see the enumeration in <a href="https://docs.spring.io/spring-framework/docs/5.3.16/javadoc-api/org/springframework/validation/DefaultMessageCodesResolver.Format.html" target="_blank" rel="noopener noreferrer"><code>DefaultMessageCodesResolver.Format</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>).</p> <h4 id="_1-1-5-static-content"><a href="#_1-1-5-static-content" class="header-anchor">#</a> 1.1.5. Static Content</h4> <p>By default, Spring Boot serves static content from a directory called <code>/static</code> (or <code>/public</code> or <code>/resources</code> or <code>/META-INF/resources</code>) in the classpath or from the root of the <code>ServletContext</code>.
It uses the <code>ResourceHttpRequestHandler</code> from Spring MVC so that you can modify that behavior by adding your own <code>WebMvcConfigurer</code> and overriding the <code>addResourceHandlers</code> method.</p> <p>In a stand-alone web application, the default servlet from the container is also enabled and acts as a fallback, serving content from the root of the <code>ServletContext</code> if Spring decides not to handle it.
Most of the time, this does not happen (unless you modify the default MVC configuration), because Spring can always handle requests through the <code>DispatcherServlet</code>.</p> <p>By default, resources are mapped on <code>/**</code>, but you can tune that with the <code>spring.mvc.static-path-pattern</code> property.
For instance, relocating all resources to <code>/resources/**</code> can be achieved as follows:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.mvc.static-path-pattern=/resources/**
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  mvc:
    static-path-pattern: &quot;/resources/**&quot;
</code></pre></div><p>You can also customize the static resource locations by using the <code>spring.web.resources.static-locations</code> property (replacing the default values with a list of directory locations).
The root servlet context path, <code>&quot;/&quot;</code>, is automatically added as a location as well.</p> <p>In addition to the “standard” static resource locations mentioned earlier, a special case is made for <a href="https://www.webjars.org/" target="_blank" rel="noopener noreferrer">Webjars content<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.
Any resources with a path in <code>/webjars/**</code> are served from jar files if they are packaged in the Webjars format.</p> <table><thead><tr><th></th> <th>Do not use the <code>src/main/webapp</code> directory if your application is packaged as a jar.<br>Although this directory is a common standard, it works <strong>only</strong> with war packaging, and it is silently ignored by most build tools if you generate a jar.</th></tr></thead> <tbody></tbody></table> <p>Spring Boot also supports the advanced resource handling features provided by Spring MVC, allowing use cases such as cache-busting static resources or using version agnostic URLs for Webjars.</p> <p>To use version agnostic URLs for Webjars, add the <code>webjars-locator-core</code> dependency.
Then declare your Webjar.
Using jQuery as an example, adding <code>&quot;/webjars/jquery/jquery.min.js&quot;</code> results in <code>&quot;/webjars/jquery/x.y.z/jquery.min.js&quot;</code> where <code>x.y.z</code> is the Webjar version.</p> <table><thead><tr><th></th> <th>If you use JBoss, you need to declare the <code>webjars-locator-jboss-vfs</code> dependency instead of the <code>webjars-locator-core</code>.<br>Otherwise, all Webjars resolve as a <code>404</code>.</th></tr></thead> <tbody></tbody></table> <p>To use cache busting, the following configuration configures a cache busting solution for all static resources, effectively adding a content hash, such as <code>&lt;link href=&quot;/css/spring-2a2d595e6ed9a0b24f027f2b63b134d6.css&quot;/&gt;</code>, in URLs:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.web.resources.chain.strategy.content.enabled=true
spring.web.resources.chain.strategy.content.paths=/**
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  web:
    resources:
      chain:
        strategy:
          content:
            enabled: true
            paths: &quot;/**&quot;
</code></pre></div><table><thead><tr><th></th> <th>Links to resources are rewritten in templates at runtime, thanks to a <code>ResourceUrlEncodingFilter</code> that is auto-configured for Thymeleaf and FreeMarker.<br>You should manually declare this filter when using JSPs.<br>Other template engines are currently not automatically supported but can be with custom template macros/helpers and the use of the <a href="https://docs.spring.io/spring-framework/docs/5.3.16/javadoc-api/org/springframework/web/servlet/resource/ResourceUrlProvider.html" target="_blank" rel="noopener noreferrer"><code>ResourceUrlProvider</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</th></tr></thead> <tbody></tbody></table> <p>When loading resources dynamically with, for example, a JavaScript module loader, renaming files is not an option.
That is why other strategies are also supported and can be combined.
A &quot;fixed&quot; strategy adds a static version string in the URL without changing the file name, as shown in the following example:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.web.resources.chain.strategy.content.enabled=true
spring.web.resources.chain.strategy.content.paths=/**
spring.web.resources.chain.strategy.fixed.enabled=true
spring.web.resources.chain.strategy.fixed.paths=/js/lib/
spring.web.resources.chain.strategy.fixed.version=v12
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  web:
    resources:
      chain:
        strategy:
          content:
            enabled: true
            paths: &quot;/**&quot;
          fixed:
            enabled: true
            paths: &quot;/js/lib/&quot;
            version: &quot;v12&quot;
</code></pre></div><p>With this configuration, JavaScript modules located under <code>&quot;/js/lib/&quot;</code> use a fixed versioning strategy (<code>&quot;/v12/js/lib/mymodule.js&quot;</code>), while other resources still use the content one (<code>&lt;link href=&quot;/css/spring-2a2d595e6ed9a0b24f027f2b63b134d6.css&quot;/&gt;</code>).</p> <p>See <a href="https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebProperties.java" target="_blank" rel="noopener noreferrer"><code>WebProperties.Resources</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> for more supported options.</p> <table><thead><tr><th></th> <th>This feature has been thoroughly described in a dedicated <a href="https://spring.io/blog/2014/07/24/spring-framework-4-1-handling-static-web-resources" target="_blank" rel="noopener noreferrer">blog post<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> and in Spring Framework’s <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-config-static-resources" target="_blank" rel="noopener noreferrer">reference documentation<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-1-6-welcome-page"><a href="#_1-1-6-welcome-page" class="header-anchor">#</a> 1.1.6. Welcome Page</h4> <p>Spring Boot supports both static and templated welcome pages.
It first looks for an <code>index.html</code> file in the configured static content locations.
If one is not found, it then looks for an <code>index</code> template.
If either is found, it is automatically used as the welcome page of the application.</p> <h4 id="_1-1-7-path-matching-and-content-negotiation"><a href="#_1-1-7-path-matching-and-content-negotiation" class="header-anchor">#</a> 1.1.7. Path Matching and Content Negotiation</h4> <p>Spring MVC can map incoming HTTP requests to handlers by looking at the request path and matching it to the mappings defined in your application (for example, <code>@GetMapping</code> annotations on Controller methods).</p> <p>Spring Boot chooses to disable suffix pattern matching by default, which means that requests like <code>&quot;GET /projects/spring-boot.json&quot;</code> will not be matched to <code>@GetMapping(&quot;/projects/spring-boot&quot;)</code> mappings.
This is considered as a <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-ann-requestmapping-suffix-pattern-match" target="_blank" rel="noopener noreferrer">best practice for Spring MVC applications<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.
This feature was mainly useful in the past for HTTP clients which did not send proper &quot;Accept&quot; request headers; we needed to make sure to send the correct Content Type to the client.
Nowadays, Content Negotiation is much more reliable.</p> <p>There are other ways to deal with HTTP clients that do not consistently send proper &quot;Accept&quot; request headers.
Instead of using suffix matching, we can use a query parameter to ensure that requests like <code>&quot;GET /projects/spring-boot?format=json&quot;</code> will be mapped to <code>@GetMapping(&quot;/projects/spring-boot&quot;)</code>:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.mvc.contentnegotiation.favor-parameter=true
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  mvc:
    contentnegotiation:
      favor-parameter: true
</code></pre></div><p>Or if you prefer to use a different parameter name:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.mvc.contentnegotiation.favor-parameter=true
spring.mvc.contentnegotiation.parameter-name=myparam
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  mvc:
    contentnegotiation:
      favor-parameter: true
      parameter-name: &quot;myparam&quot;
</code></pre></div><p>Most standard media types are supported out-of-the-box, but you can also define new ones:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.mvc.contentnegotiation.media-types.markdown=text/markdown
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  mvc:
    contentnegotiation:
      media-types:
        markdown: &quot;text/markdown&quot;
</code></pre></div><p>Suffix pattern matching is deprecated and will be removed in a future release.
If you understand the caveats and would still like your application to use suffix pattern matching, the following configuration is required:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.mvc.contentnegotiation.favor-path-extension=true
spring.mvc.pathmatch.use-suffix-pattern=true
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  mvc:
    contentnegotiation:
      favor-path-extension: true
    pathmatch:
      use-suffix-pattern: true
</code></pre></div><p>Alternatively, rather than open all suffix patterns, it is more secure to only support registered suffix patterns:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.mvc.contentnegotiation.favor-path-extension=true
spring.mvc.pathmatch.use-registered-suffix-pattern=true
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  mvc:
    contentnegotiation:
      favor-path-extension: true
    pathmatch:
      use-registered-suffix-pattern: true
</code></pre></div><p>As of Spring Framework 5.3, Spring MVC supports several implementation strategies for matching request paths to Controller handlers.
It was previously only supporting the <code>AntPathMatcher</code> strategy, but it now also offers <code>PathPatternParser</code>.
Spring Boot now provides a configuration property to choose and opt in the new strategy:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.mvc.pathmatch.matching-strategy=path-pattern-parser
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  mvc:
    pathmatch:
      matching-strategy: &quot;path-pattern-parser&quot;
</code></pre></div><p>For more details on why you should consider this new implementation, see the<a href="https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc" target="_blank" rel="noopener noreferrer">dedicated blog post<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <table><thead><tr><th></th> <th><code>PathPatternParser</code> is an optimized implementation but restricts usage of<a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-ann-requestmapping-uri-templates" target="_blank" rel="noopener noreferrer">some path patterns variants<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>and is incompatible with suffix pattern matching (<code>spring.mvc.pathmatch.use-suffix-pattern</code>,<code>spring.mvc.pathmatch.use-registered-suffix-pattern</code>) or mapping the <code>DispatcherServlet</code>with a servlet prefix (<code>spring.mvc.servlet.path</code>).</th></tr></thead> <tbody></tbody></table> <h4 id="_1-1-8-configurablewebbindinginitializer"><a href="#_1-1-8-configurablewebbindinginitializer" class="header-anchor">#</a> 1.1.8. ConfigurableWebBindingInitializer</h4> <p>Spring MVC uses a <code>WebBindingInitializer</code> to initialize a <code>WebDataBinder</code> for a particular request.
If you create your own <code>ConfigurableWebBindingInitializer</code> <code>@Bean</code>, Spring Boot automatically configures Spring MVC to use it.</p> <h4 id="_1-1-9-template-engines"><a href="#_1-1-9-template-engines" class="header-anchor">#</a> 1.1.9. Template Engines</h4> <p>As well as REST web services, you can also use Spring MVC to serve dynamic HTML content.
Spring MVC supports a variety of templating technologies, including Thymeleaf, FreeMarker, and JSPs.
Also, many other templating engines include their own Spring MVC integrations.</p> <p>Spring Boot includes auto-configuration support for the following templating engines:</p> <ul><li><p><a href="https://freemarker.apache.org/docs/" target="_blank" rel="noopener noreferrer">FreeMarker<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html#_the_markuptemplateengine" target="_blank" rel="noopener noreferrer">Groovy<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://www.thymeleaf.org" target="_blank" rel="noopener noreferrer">Thymeleaf<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://mustache.github.io/" target="_blank" rel="noopener noreferrer">Mustache<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li></ul> <table><thead><tr><th></th> <th>If possible, JSPs should be avoided.<br>There are several <a href="#web.servlet.embedded-container.jsp-limitations">known limitations</a> when using them with embedded servlet containers.</th></tr></thead> <tbody></tbody></table> <p>When you use one of these templating engines with the default configuration, your templates are picked up automatically from <code>src/main/resources/templates</code>.</p> <table><thead><tr><th></th> <th>Depending on how you run your application, your IDE may order the classpath differently.<br>Running your application in the IDE from its main method results in a different ordering than when you run your application by using Maven or Gradle or from its packaged jar.<br>This can cause Spring Boot to fail to find the expected template.<br>If you have this problem, you can reorder the classpath in the IDE to place the module’s classes and resources first.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-1-10-error-handling"><a href="#_1-1-10-error-handling" class="header-anchor">#</a> 1.1.10. Error Handling</h4> <p>By default, Spring Boot provides an <code>/error</code> mapping that handles all errors in a sensible way, and it is registered as a “global” error page in the servlet container.
For machine clients, it produces a JSON response with details of the error, the HTTP status, and the exception message.
For browser clients, there is a “whitelabel” error view that renders the same data in HTML format (to customize it, add a <code>View</code> that resolves to <code>error</code>).</p> <p>There are a number of <code>server.error</code> properties that can be set if you want to customize the default error handling behavior.
See the <a href="/en/spring-boot/application-properties.html#appendix.application-properties.server">“Server Properties”</a> section of the Appendix.</p> <p>To replace the default behavior completely, you can implement <code>ErrorController</code> and register a bean definition of that type or add a bean of type <code>ErrorAttributes</code> to use the existing mechanism but replace the contents.</p> <table><thead><tr><th></th> <th>The <code>BasicErrorController</code> can be used as a base class for a custom <code>ErrorController</code>.<br>This is particularly useful if you want to add a handler for a new content type (the default is to handle <code>text/html</code> specifically and provide a fallback for everything else).<br>To do so, extend <code>BasicErrorController</code>, add a public method with a <code>@RequestMapping</code> that has a <code>produces</code> attribute, and create a bean of your new type.</th></tr></thead> <tbody></tbody></table> <p>You can also define a class annotated with <code>@ControllerAdvice</code> to customize the JSON document to return for a particular controller and/or exception type, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@ControllerAdvice(basePackageClasses = SomeController.class)
public class MyControllerAdvice extends ResponseEntityExceptionHandler {

    @ResponseBody
    @ExceptionHandler(MyException.class)
    public ResponseEntity&lt;?&gt; handleControllerException(HttpServletRequest request, Throwable ex) {
        HttpStatus status = getStatus(request);
        return new ResponseEntity&lt;&gt;(new MyErrorBody(status.value(), ex.getMessage()), status);
    }

    private HttpStatus getStatus(HttpServletRequest request) {
        Integer code = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
        HttpStatus status = HttpStatus.resolve(code);
        return (status != null) ? status : HttpStatus.INTERNAL_SERVER_ERROR;
    }

}

</code></pre></div><p>In the preceding example, if <code>YourException</code> is thrown by a controller defined in the same package as <code>SomeController</code>, a JSON representation of the <code>CustomErrorType</code> POJO is used instead of the <code>ErrorAttributes</code> representation.</p> <p>In some cases, errors handled at the controller level are not recorded by the <a href="/en/spring-boot/actuator.html#actuator.metrics.supported.spring-mvc">metrics infrastructure</a>.
Applications can ensure that such exceptions are recorded with the request metrics by setting the handled exception as a request attribute:</p> <div class="language- extra-class"><pre class="language-text"><code>import javax.servlet.http.HttpServletRequest;

import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;

@Controller
public class MyController {

    @ExceptionHandler(CustomException.class)
    String handleCustomException(HttpServletRequest request, CustomException ex) {
        request.setAttribute(ErrorAttributes.ERROR_ATTRIBUTE, ex);
        return &quot;errorView&quot;;
    }

}

</code></pre></div><h5 id="custom-error-pages"><a href="#custom-error-pages" class="header-anchor">#</a> Custom Error Pages</h5> <p>If you want to display a custom HTML error page for a given status code, you can add a file to an <code>/error</code> directory.
Error pages can either be static HTML (that is, added under any of the static resource directories) or be built by using templates.
The name of the file should be the exact status code or a series mask.</p> <p>For example, to map <code>404</code> to a static HTML file, your directory structure would be as follows:</p> <div class="language- extra-class"><pre class="language-text"><code>src/
 +- main/
     +- java/
     |   + &lt;source code&gt;
     +- resources/
         +- public/
             +- error/
             |   +- 404.html
             +- &lt;other public assets&gt;
</code></pre></div><p>To map all <code>5xx</code> errors by using a FreeMarker template, your directory structure would be as follows:</p> <div class="language- extra-class"><pre class="language-text"><code>src/
 +- main/
     +- java/
     |   + &lt;source code&gt;
     +- resources/
         +- templates/
             +- error/
             |   +- 5xx.ftlh
             +- &lt;other templates&gt;
</code></pre></div><p>For more complex mappings, you can also add beans that implement the <code>ErrorViewResolver</code> interface, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.ModelAndView;

public class MyErrorViewResolver implements ErrorViewResolver {

    @Override
    public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map&lt;String, Object&gt; model) {
        // Use the request or status to optionally return a ModelAndView
        if (status == HttpStatus.INSUFFICIENT_STORAGE) {
            // We could add custom model values here
            new ModelAndView(&quot;myview&quot;);
        }
        return null;
    }

}

</code></pre></div><p>You can also use regular Spring MVC features such as <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-exceptionhandlers" target="_blank" rel="noopener noreferrer"><code>@ExceptionHandler</code> methods<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> and <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-ann-controller-advice" target="_blank" rel="noopener noreferrer"><code>@ControllerAdvice</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.
The <code>ErrorController</code> then picks up any unhandled exceptions.</p> <h5 id="mapping-error-pages-outside-of-spring-mvc"><a href="#mapping-error-pages-outside-of-spring-mvc" class="header-anchor">#</a> Mapping Error Pages outside of Spring MVC</h5> <p>For applications that do not use Spring MVC, you can use the <code>ErrorPageRegistrar</code> interface to directly register <code>ErrorPages</code>.
This abstraction works directly with the underlying embedded servlet container and works even if you do not have a Spring MVC <code>DispatcherServlet</code>.</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

@Configuration(proxyBeanMethods = false)
public class MyErrorPagesConfiguration {

    @Bean
    public ErrorPageRegistrar errorPageRegistrar() {
        return this::registerErrorPages;
    }

    private void registerErrorPages(ErrorPageRegistry registry) {
        registry.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, &quot;/400&quot;));
    }

}

</code></pre></div><table><thead><tr><th></th> <th>If you register an <code>ErrorPage</code> with a path that ends up being handled by a <code>Filter</code> (as is common with some non-Spring web frameworks, like Jersey and Wicket), then the <code>Filter</code> has to be explicitly registered as an <code>ERROR</code> dispatcher, as shown in the following example:</th></tr></thead> <tbody></tbody></table> <div class="language- extra-class"><pre class="language-text"><code>import java.util.EnumSet;

import javax.servlet.DispatcherType;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
public class MyFilterConfiguration {

    @Bean
    public FilterRegistrationBean&lt;MyFilter&gt; myFilter() {
        FilterRegistrationBean&lt;MyFilter&gt; registration = new FilterRegistrationBean&lt;&gt;(new MyFilter());
        // ...
        registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
        return registration;
    }

}

</code></pre></div><p>Note that the default <code>FilterRegistrationBean</code> does not include the <code>ERROR</code> dispatcher type.</p> <h5 id="error-handling-in-a-war-deployment"><a href="#error-handling-in-a-war-deployment" class="header-anchor">#</a> Error handling in a war deployment</h5> <p>When deployed to a servlet container, Spring Boot uses its error page filter to forward a request with an error status to the appropriate error page.
This is necessary as the servlet specification does not provide an API for registering error pages.
Depending on the container that you are deploying your war file to and the technologies that your application uses, some additional configuration may be required.</p> <p>The error page filter can only forward the request to the correct error page if the response has not already been committed.
By default, WebSphere Application Server 8.0 and later commits the response upon successful completion of a servlet’s service method.
You should disable this behavior by setting <code>com.ibm.ws.webcontainer.invokeFlushAfterService</code> to <code>false</code>.</p> <p>If you are using Spring Security and want to access the principal in an error page, you must configure Spring Security’s filter to be invoked on error dispatches.
To do so, set the <code>spring.security.filter.dispatcher-types</code> property to <code>async, error, forward, request</code>.</p> <h4 id="_1-1-11-cors-support"><a href="#_1-1-11-cors-support" class="header-anchor">#</a> 1.1.11. CORS Support</h4> <p><a href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing" target="_blank" rel="noopener noreferrer">Cross-origin resource sharing<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> (CORS) is a <a href="https://www.w3.org/TR/cors/" target="_blank" rel="noopener noreferrer">W3C specification<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> implemented by <a href="https://caniuse.com/#feat=cors" target="_blank" rel="noopener noreferrer">most browsers<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> that lets you specify in a flexible way what kind of cross-domain requests are authorized, instead of using some less secure and less powerful approaches such as IFRAME or JSONP.</p> <p>As of version 4.2, Spring MVC <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-cors" target="_blank" rel="noopener noreferrer">supports CORS<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.
Using <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-cors-controller" target="_blank" rel="noopener noreferrer">controller method CORS configuration<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> with <a href="https://docs.spring.io/spring-framework/docs/5.3.16/javadoc-api/org/springframework/web/bind/annotation/CrossOrigin.html" target="_blank" rel="noopener noreferrer"><code>@CrossOrigin</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> annotations in your Spring Boot application does not require any specific configuration.<a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc-cors-global" target="_blank" rel="noopener noreferrer">Global CORS configuration<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> can be defined by registering a <code>WebMvcConfigurer</code> bean with a customized <code>addCorsMappings(CorsRegistry)</code> method, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration(proxyBeanMethods = false)
public class MyCorsConfiguration {

    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {

            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping(&quot;/api/**&quot;);
            }

        };
    }

}

</code></pre></div><h3 id="_1-2-jax-rs-and-jersey"><a href="#_1-2-jax-rs-and-jersey" class="header-anchor">#</a> 1.2. JAX-RS and Jersey</h3> <p>If you prefer the JAX-RS programming model for REST endpoints, you can use one of the available implementations instead of Spring MVC.<a href="https://jersey.github.io/" target="_blank" rel="noopener noreferrer">Jersey<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> and <a href="https://cxf.apache.org/" target="_blank" rel="noopener noreferrer">Apache CXF<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> work quite well out of the box.
CXF requires you to register its <code>Servlet</code> or <code>Filter</code> as a <code>@Bean</code> in your application context.
Jersey has some native Spring support, so we also provide auto-configuration support for it in Spring Boot, together with a starter.</p> <p>To get started with Jersey, include the <code>spring-boot-starter-jersey</code> as a dependency and then you need one <code>@Bean</code> of type <code>ResourceConfig</code> in which you register all the endpoints, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.glassfish.jersey.server.ResourceConfig;

import org.springframework.stereotype.Component;

@Component
public class MyJerseyConfig extends ResourceConfig {

    public MyJerseyConfig() {
        register(MyEndpoint.class);
    }

}

</code></pre></div><table><thead><tr><th></th> <th>Jersey’s support for scanning executable archives is rather limited.<br>For example, it cannot scan for endpoints in a package found in a <a href="/en/spring-boot/deployment.html#deployment.installing">fully executable jar file</a> or in <code>WEB-INF/classes</code> when running an executable war file.<br>To avoid this limitation, the <code>packages</code> method should not be used, and endpoints should be registered individually by using the <code>register</code> method, as shown in the preceding example.</th></tr></thead> <tbody></tbody></table> <p>For more advanced customizations, you can also register an arbitrary number of beans that implement <code>ResourceConfigCustomizer</code>.</p> <p>All the registered endpoints should be <code>@Components</code> with HTTP resource annotations (<code>@GET</code> and others), as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.springframework.stereotype.Component;

@Component
@Path(&quot;/hello&quot;)
public class MyEndpoint {

    @GET
    public String message() {
        return &quot;Hello&quot;;
    }

}

</code></pre></div><p>Since the <code>Endpoint</code> is a Spring <code>@Component</code>, its lifecycle is managed by Spring and you can use the <code>@Autowired</code> annotation to inject dependencies and use the <code>@Value</code> annotation to inject external configuration.
By default, the Jersey servlet is registered and mapped to <code>/*</code>.
You can change the mapping by adding <code>@ApplicationPath</code> to your <code>ResourceConfig</code>.</p> <p>By default, Jersey is set up as a servlet in a <code>@Bean</code> of type <code>ServletRegistrationBean</code> named <code>jerseyServletRegistration</code>.
By default, the servlet is initialized lazily, but you can customize that behavior by setting <code>spring.jersey.servlet.load-on-startup</code>.
You can disable or override that bean by creating one of your own with the same name.
You can also use a filter instead of a servlet by setting <code>spring.jersey.type=filter</code> (in which case, the <code>@Bean</code> to replace or override is <code>jerseyFilterRegistration</code>).
The filter has an <code>@Order</code>, which you can set with <code>spring.jersey.filter.order</code>.
When using Jersey as a filter, a servlet that will handle any requests that are not intercepted by Jersey must be present.
If your application does not contain such a servlet, you may want to enable the default servlet by setting <code>server.servlet.register-default-servlet</code> to <code>true</code>.
Both the servlet and the filter registrations can be given init parameters by using <code>spring.jersey.init.*</code> to specify a map of properties.</p> <h3 id="_1-3-embedded-servlet-container-support"><a href="#_1-3-embedded-servlet-container-support" class="header-anchor">#</a> 1.3. Embedded Servlet Container Support</h3> <p>For servlet application, Spring Boot includes support for embedded <a href="https://tomcat.apache.org/" target="_blank" rel="noopener noreferrer">Tomcat<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>, <a href="https://www.eclipse.org/jetty/" target="_blank" rel="noopener noreferrer">Jetty<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>, and <a href="https://github.com/undertow-io/undertow" target="_blank" rel="noopener noreferrer">Undertow<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> servers.
Most developers use the appropriate “Starter” to obtain a fully configured instance.
By default, the embedded server listens for HTTP requests on port <code>8080</code>.</p> <h4 id="_1-3-1-servlets-filters-and-listeners"><a href="#_1-3-1-servlets-filters-and-listeners" class="header-anchor">#</a> 1.3.1. Servlets, Filters, and listeners</h4> <p>When using an embedded servlet container, you can register servlets, filters, and all the listeners (such as <code>HttpSessionListener</code>) from the servlet spec, either by using Spring beans or by scanning for servlet components.</p> <h5 id="registering-servlets-filters-and-listeners-as-spring-beans"><a href="#registering-servlets-filters-and-listeners-as-spring-beans" class="header-anchor">#</a> Registering Servlets, Filters, and Listeners as Spring Beans</h5> <p>Any <code>Servlet</code>, <code>Filter</code>, or servlet <code>*Listener</code> instance that is a Spring bean is registered with the embedded container.
This can be particularly convenient if you want to refer to a value from your <code>application.properties</code> during configuration.</p> <p>By default, if the context contains only a single Servlet, it is mapped to <code>/</code>.
In the case of multiple servlet beans, the bean name is used as a path prefix.
Filters map to <code>/*</code>.</p> <p>If convention-based mapping is not flexible enough, you can use the <code>ServletRegistrationBean</code>, <code>FilterRegistrationBean</code>, and <code>ServletListenerRegistrationBean</code> classes for complete control.</p> <p>It is usually safe to leave filter beans unordered.
If a specific order is required, you should annotate the <code>Filter</code> with <code>@Order</code> or make it implement <code>Ordered</code>.
You cannot configure the order of a <code>Filter</code> by annotating its bean method with <code>@Order</code>.
If you cannot change the <code>Filter</code> class to add <code>@Order</code> or implement <code>Ordered</code>, you must define a <code>FilterRegistrationBean</code> for the <code>Filter</code> and set the registration bean’s order using the <code>setOrder(int)</code> method.
Avoid configuring a filter that reads the request body at <code>Ordered.HIGHEST_PRECEDENCE</code>, since it might go against the character encoding configuration of your application.
If a servlet filter wraps the request, it should be configured with an order that is less than or equal to <code>OrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER</code>.</p> <table><thead><tr><th></th> <th>To see the order of every <code>Filter</code> in your application, enable debug level logging for the <code>web</code> <a href="/en/spring-boot/features.html#features.logging.log-groups">logging group</a> (<code>logging.level.web=debug</code>).<br>Details of the registered filters, including their order and URL patterns, will then be logged at startup.</th></tr></thead> <tbody></tbody></table> <table><thead><tr><th></th> <th>Take care when registering <code>Filter</code> beans since they are initialized very early in the application lifecycle.<br>If you need to register a <code>Filter</code> that interacts with other beans, consider using a <a href="https://docs.spring.io/spring-boot/docs/2.6.4/api/org/springframework/boot/web/servlet/DelegatingFilterProxyRegistrationBean.html" target="_blank" rel="noopener noreferrer"><code>DelegatingFilterProxyRegistrationBean</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> instead.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-3-2-servlet-context-initialization"><a href="#_1-3-2-servlet-context-initialization" class="header-anchor">#</a> 1.3.2. Servlet Context Initialization</h4> <p>Embedded servlet containers do not directly execute the servlet 3.0+ <code>javax.servlet.ServletContainerInitializer</code> interface or Spring’s <code>org.springframework.web.WebApplicationInitializer</code> interface.
This is an intentional design decision intended to reduce the risk that third party libraries designed to run inside a war may break Spring Boot applications.</p> <p>If you need to perform servlet context initialization in a Spring Boot application, you should register a bean that implements the <code>org.springframework.boot.web.servlet.ServletContextInitializer</code> interface.
The single <code>onStartup</code> method provides access to the <code>ServletContext</code> and, if necessary, can easily be used as an adapter to an existing <code>WebApplicationInitializer</code>.</p> <h5 id="scanning-for-servlets-filters-and-listeners"><a href="#scanning-for-servlets-filters-and-listeners" class="header-anchor">#</a> Scanning for Servlets, Filters, and listeners</h5> <p>When using an embedded container, automatic registration of classes annotated with <code>@WebServlet</code>, <code>@WebFilter</code>, and <code>@WebListener</code> can be enabled by using <code>@ServletComponentScan</code>.</p> <table><thead><tr><th></th> <th><code>@ServletComponentScan</code> has no effect in a standalone container, where the container’s built-in discovery mechanisms are used instead.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-3-3-the-servletwebserverapplicationcontext"><a href="#_1-3-3-the-servletwebserverapplicationcontext" class="header-anchor">#</a> 1.3.3. The ServletWebServerApplicationContext</h4> <p>Under the hood, Spring Boot uses a different type of <code>ApplicationContext</code> for embedded servlet container support.
The <code>ServletWebServerApplicationContext</code> is a special type of <code>WebApplicationContext</code> that bootstraps itself by searching for a single <code>ServletWebServerFactory</code> bean.
Usually a <code>TomcatServletWebServerFactory</code>, <code>JettyServletWebServerFactory</code>, or <code>UndertowServletWebServerFactory</code> has been auto-configured.</p> <table><thead><tr><th></th> <th>You usually do not need to be aware of these implementation classes.<br>Most applications are auto-configured, and the appropriate <code>ApplicationContext</code> and <code>ServletWebServerFactory</code> are created on your behalf.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-3-4-customizing-embedded-servlet-containers"><a href="#_1-3-4-customizing-embedded-servlet-containers" class="header-anchor">#</a> 1.3.4. Customizing Embedded Servlet Containers</h4> <p>Common servlet container settings can be configured by using Spring <code>Environment</code> properties.
Usually, you would define the properties in your <code>application.properties</code> or <code>application.yaml</code> file.</p> <p>Common server settings include:</p> <ul><li><p>Network settings: Listen port for incoming HTTP requests (<code>server.port</code>), interface address to bind to <code>server.address</code>, and so on.</p></li> <li><p>Session settings: Whether the session is persistent (<code>server.servlet.session.persistent</code>), session timeout (<code>server.servlet.session.timeout</code>), location of session data (<code>server.servlet.session.store-dir</code>), and session-cookie configuration (<code>server.servlet.session.cookie.*</code>).</p></li> <li><p>Error management: Location of the error page (<code>server.error.path</code>) and so on.</p></li> <li><p><a href="/en/spring-boot/howto.html#howto.webserver.configure-ssl">SSL</a></p></li> <li><p><a href="/en/spring-boot/howto.html#howto.webserver.enable-response-compression">HTTP compression</a></p></li></ul> <p>Spring Boot tries as much as possible to expose common settings, but this is not always possible.
For those cases, dedicated namespaces offer server-specific customizations (see <code>server.tomcat</code> and <code>server.undertow</code>).
For instance, <a href="/en/spring-boot/howto.html#howto.webserver.configure-access-logs">access logs</a> can be configured with specific features of the embedded servlet container.</p> <table><thead><tr><th></th> <th>See the <a href="https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java" target="_blank" rel="noopener noreferrer"><code>ServerProperties</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> class for a complete list.</th></tr></thead> <tbody></tbody></table> <h5 id="samesite-cookies"><a href="#samesite-cookies" class="header-anchor">#</a> SameSite Cookies</h5> <p>The <code>SameSite</code> cookie attribute can be used by web browsers to control if and how cookies are submitted in cross-site requests.
The attribute is particularly relevant for modern web browsers which have started to change the default value that is used when the attribute is missing.</p> <p>If you want to change the <code>SameSite</code> attribute of your session cookie, you can use the <code>server.servlet.session.cookie.same-site</code> property.
This property is supported by auto-configured Tomcat, Jetty and Undertow servers.
It is also used to configure Spring Session servlet based <code>SessionRepository</code> beans.</p> <p>For example, if you want your session cookie to have a <code>SameSite</code> attribute of <code>None</code>, you can add the following to your <code>application.properties</code> or <code>application.yaml</code> file:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>server.servlet.session.cookie.same-site=none
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>server:
  servlet:
    session:
      cookie:
        same-site: &quot;none&quot;
</code></pre></div><p>If you want to change the <code>SameSite</code> attribute on other cookies added to your <code>HttpServletResponse</code>, you can use a <code>CookieSameSiteSupplier</code>.
The <code>CookieSameSiteSupplier</code> is passed a <code>Cookie</code> and may return a <code>SameSite</code> value, or <code>null</code>.</p> <p>There are a number of convenience factory and filter methods that you can use to quickly match specific cookies.
For example, adding the following bean will automatically apply a <code>SameSite</code> of <code>Lax</code> for all cookies with a name that matches the regular expression <code>myapp.*</code>.</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.boot.web.servlet.server.CookieSameSiteSupplier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
public class MySameSiteConfiguration {

    @Bean
    public CookieSameSiteSupplier applicationCookieSameSiteSupplier() {
        return CookieSameSiteSupplier.ofLax().whenHasNameMatching(&quot;myapp.*&quot;);
    }

}

</code></pre></div><h5 id="programmatic-customization"><a href="#programmatic-customization" class="header-anchor">#</a> Programmatic Customization</h5> <p>If you need to programmatically configure your embedded servlet container, you can register a Spring bean that implements the <code>WebServerFactoryCustomizer</code> interface.<code>WebServerFactoryCustomizer</code> provides access to the <code>ConfigurableServletWebServerFactory</code>, which includes numerous customization setter methods.
The following example shows programmatically setting the port:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.stereotype.Component;

@Component
public class MyWebServerFactoryCustomizer implements WebServerFactoryCustomizer&lt;ConfigurableServletWebServerFactory&gt; {

    @Override
    public void customize(ConfigurableServletWebServerFactory server) {
        server.setPort(9000);
    }

}

</code></pre></div><p><code>TomcatServletWebServerFactory</code>, <code>JettyServletWebServerFactory</code> and <code>UndertowServletWebServerFactory</code> are dedicated variants of <code>ConfigurableServletWebServerFactory</code> that have additional customization setter methods for Tomcat, Jetty and Undertow respectively.
The following example shows how to customize <code>TomcatServletWebServerFactory</code> that provides access to Tomcat-specific configuration options:</p> <div class="language- extra-class"><pre class="language-text"><code>import java.time.Duration;

import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;

@Component
public class MyTomcatWebServerFactoryCustomizer implements WebServerFactoryCustomizer&lt;TomcatServletWebServerFactory&gt; {

    @Override
    public void customize(TomcatServletWebServerFactory server) {
        server.addConnectorCustomizers((connector) -&gt; connector.setAsyncTimeout(Duration.ofSeconds(20).toMillis()));
    }

}

</code></pre></div><h5 id="customizing-configurableservletwebserverfactory-directly"><a href="#customizing-configurableservletwebserverfactory-directly" class="header-anchor">#</a> Customizing ConfigurableServletWebServerFactory Directly</h5> <p>For more advanced use cases that require you to extend from <code>ServletWebServerFactory</code>, you can expose a bean of such type yourself.</p> <p>Setters are provided for many configuration options.
Several protected method “hooks” are also provided should you need to do something more exotic.
See the <a href="https://docs.spring.io/spring-boot/docs/2.6.4/api/org/springframework/boot/web/servlet/server/ConfigurableServletWebServerFactory.html" target="_blank" rel="noopener noreferrer">source code documentation<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> for details.</p> <table><thead><tr><th></th> <th>Auto-configured customizers are still applied on your custom factory, so use that option carefully.</th></tr></thead> <tbody></tbody></table> <h4 id="_1-3-5-jsp-limitations"><a href="#_1-3-5-jsp-limitations" class="header-anchor">#</a> 1.3.5. JSP Limitations</h4> <p>When running a Spring Boot application that uses an embedded servlet container (and is packaged as an executable archive), there are some limitations in the JSP support.</p> <ul><li><p>With Jetty and Tomcat, it should work if you use war packaging.
An executable war will work when launched with <code>java -jar</code>, and will also be deployable to any standard container.
JSPs are not supported when using an executable jar.</p></li> <li><p>Undertow does not support JSPs.</p></li> <li><p>Creating a custom <code>error.jsp</code> page does not override the default view for <a href="#web.servlet.spring-mvc.error-handling">error handling</a>.<a href="#web.servlet.spring-mvc.error-handling.error-pages">Custom error pages</a> should be used instead.</p></li></ul> <h2 id="_2-reactive-web-applications"><a href="#_2-reactive-web-applications" class="header-anchor">#</a> 2. Reactive Web Applications</h2> <p>Spring Boot simplifies development of reactive web applications by providing auto-configuration for Spring Webflux.</p> <h3 id="_2-1-the-spring-webflux-framework"><a href="#_2-1-the-spring-webflux-framework" class="header-anchor">#</a> 2.1. The “Spring WebFlux Framework”</h3> <p>Spring WebFlux is the new reactive web framework introduced in Spring Framework 5.0.
Unlike Spring MVC, it does not require the servlet API, is fully asynchronous and non-blocking, and implements the <a href="https://www.reactive-streams.org/" target="_blank" rel="noopener noreferrer">Reactive Streams<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> specification through <a href="https://projectreactor.io/" target="_blank" rel="noopener noreferrer">the Reactor project<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <p>Spring WebFlux comes in two flavors: functional and annotation-based.
The annotation-based one is quite close to the Spring MVC model, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(&quot;/users&quot;)
public class MyRestController {

    private final UserRepository userRepository;

    private final CustomerRepository customerRepository;

    public MyRestController(UserRepository userRepository, CustomerRepository customerRepository) {
        this.userRepository = userRepository;
        this.customerRepository = customerRepository;
    }

    @GetMapping(&quot;/{user}&quot;)
    public Mono&lt;User&gt; getUser(@PathVariable Long userId) {
        return this.userRepository.findById(userId);
    }

    @GetMapping(&quot;/{user}/customers&quot;)
    public Flux&lt;Customer&gt; getUserCustomers(@PathVariable Long userId) {
        return this.userRepository.findById(userId).flatMapMany(this.customerRepository::findByUser);
    }

    @DeleteMapping(&quot;/{user}&quot;)
    public void deleteUser(@PathVariable Long userId) {
        this.userRepository.deleteById(userId);
    }

}

</code></pre></div><p>“WebFlux.fn”, the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicate;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

@Configuration(proxyBeanMethods = false)
public class MyRoutingConfiguration {

    private static final RequestPredicate ACCEPT_JSON = accept(MediaType.APPLICATION_JSON);

    @Bean
    public RouterFunction&lt;ServerResponse&gt; monoRouterFunction(MyUserHandler userHandler) {
        return route()
                .GET(&quot;/{user}&quot;, ACCEPT_JSON, userHandler::getUser)
                .GET(&quot;/{user}/customers&quot;, ACCEPT_JSON, userHandler::getUserCustomers)
                .DELETE(&quot;/{user}&quot;, ACCEPT_JSON, userHandler::deleteUser)
                .build();
    }

}

</code></pre></div><div class="language- extra-class"><pre class="language-text"><code>import reactor.core.publisher.Mono;

import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;

@Component
public class MyUserHandler {

    public Mono&lt;ServerResponse&gt; getUser(ServerRequest request) {
        ...
    }

    public Mono&lt;ServerResponse&gt; getUserCustomers(ServerRequest request) {
        ...
    }

    public Mono&lt;ServerResponse&gt; deleteUser(ServerRequest request) {
        ...
    }

}

</code></pre></div><p>WebFlux is part of the Spring Framework and detailed information is available in its <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web-reactive.html#webflux-fn" target="_blank" rel="noopener noreferrer">reference documentation<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <table><thead><tr><th></th> <th>You can define as many <code>RouterFunction</code> beans as you like to modularize the definition of the router.<br>Beans can be ordered if you need to apply a precedence.</th></tr></thead> <tbody></tbody></table> <p>To get started, add the <code>spring-boot-starter-webflux</code> module to your application.</p> <table><thead><tr><th></th> <th>Adding both <code>spring-boot-starter-web</code> and <code>spring-boot-starter-webflux</code> modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux.<br>This behavior has been chosen because many Spring developers add <code>spring-boot-starter-webflux</code> to their Spring MVC application to use the reactive <code>WebClient</code>.<br>You can still enforce your choice by setting the chosen application type to <code>SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)</code>.</th></tr></thead> <tbody></tbody></table> <p>“WebFlux.fn”, the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicate;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

@Configuration(proxyBeanMethods = false)
public class MyRoutingConfiguration {

    private static final RequestPredicate ACCEPT_JSON = accept(MediaType.APPLICATION_JSON);

    @Bean
    public RouterFunction&lt;ServerResponse&gt; monoRouterFunction(MyUserHandler userHandler) {
        return route()
                .GET(&quot;/{user}&quot;, ACCEPT_JSON, userHandler::getUser)
                .GET(&quot;/{user}/customers&quot;, ACCEPT_JSON, userHandler::getUserCustomers)
                .DELETE(&quot;/{user}&quot;, ACCEPT_JSON, userHandler::deleteUser)
                .build();
    }

}

</code></pre></div><div class="language- extra-class"><pre class="language-text"><code>import reactor.core.publisher.Mono;

import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;

@Component
public class MyUserHandler {

    public Mono&lt;ServerResponse&gt; getUser(ServerRequest request) {
        ...
    }

    public Mono&lt;ServerResponse&gt; getUserCustomers(ServerRequest request) {
        ...
    }

    public Mono&lt;ServerResponse&gt; deleteUser(ServerRequest request) {
        ...
    }

}

</code></pre></div><p>WebFlux is part of the Spring Framework and detailed information is available in its <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web-reactive.html#webflux-fn" target="_blank" rel="noopener noreferrer">reference documentation<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <table><thead><tr><th></th> <th>You can define as many <code>RouterFunction</code> beans as you like to modularize the definition of the router.<br>Beans can be ordered if you need to apply a precedence.</th></tr></thead> <tbody></tbody></table> <p>To get started, add the <code>spring-boot-starter-webflux</code> module to your application.</p> <table><thead><tr><th></th> <th>Adding both <code>spring-boot-starter-web</code> and <code>spring-boot-starter-webflux</code> modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux.<br>This behavior has been chosen because many Spring developers add <code>spring-boot-starter-webflux</code> to their Spring MVC application to use the reactive <code>WebClient</code>.<br>You can still enforce your choice by setting the chosen application type to <code>SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)</code>.</th></tr></thead> <tbody></tbody></table> <h4 id="_2-1-1-spring-webflux-auto-configuration"><a href="#_2-1-1-spring-webflux-auto-configuration" class="header-anchor">#</a> 2.1.1. Spring WebFlux Auto-configuration</h4> <p>Spring Boot provides auto-configuration for Spring WebFlux that works well with most applications.</p> <p>The auto-configuration adds the following features on top of Spring’s defaults:</p> <ul><li><p>Configuring codecs for <code>HttpMessageReader</code> and <code>HttpMessageWriter</code> instances (described <a href="#web.reactive.webflux.httpcodecs">later in this document</a>).</p></li> <li><p>Support for serving static resources, including support for WebJars (described <a href="#web.servlet.spring-mvc.static-content">later in this document</a>).</p></li></ul> <p>If you want to keep Spring Boot WebFlux features and you want to add additional <a href="https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web-reactive.html#webflux-config" target="_blank" rel="noopener noreferrer">WebFlux configuration<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>, you can add your own <code>@Configuration</code> class of type <code>WebFluxConfigurer</code> but <strong>without</strong> <code>@EnableWebFlux</code>.</p> <p>If you want to take complete control of Spring WebFlux, you can add your own <code>@Configuration</code> annotated with <code>@EnableWebFlux</code>.</p> <h4 id="_2-1-2-http-codecs-with-httpmessagereaders-and-httpmessagewriters"><a href="#_2-1-2-http-codecs-with-httpmessagereaders-and-httpmessagewriters" class="header-anchor">#</a> 2.1.2. HTTP Codecs with HttpMessageReaders and HttpMessageWriters</h4> <p>Spring WebFlux uses the <code>HttpMessageReader</code> and <code>HttpMessageWriter</code> interfaces to convert HTTP requests and responses.
They are configured with <code>CodecConfigurer</code> to have sensible defaults by looking at the libraries available in your classpath.</p> <p>Spring Boot provides dedicated configuration properties for codecs, <code>spring.codec.*</code>.
It also applies further customization by using <code>CodecCustomizer</code> instances.
For example, <code>spring.jackson.*</code> configuration keys are applied to the Jackson codec.</p> <p>If you need to add or customize codecs, you can create a custom <code>CodecCustomizer</code> component, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.boot.web.codec.CodecCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.codec.ServerSentEventHttpMessageReader;

@Configuration(proxyBeanMethods = false)
public class MyCodecsConfiguration {

    @Bean
    public CodecCustomizer myCodecCustomizer() {
        return (configurer) -&gt; {
            configurer.registerDefaults(false);
            configurer.customCodecs().register(new ServerSentEventHttpMessageReader());
            // ...
        };
    }

}

</code></pre></div><p>You can also leverage <a href="#web.servlet.spring-mvc.json">Boot’s custom JSON serializers and deserializers</a>.</p> <h4 id="_2-1-3-static-content"><a href="#_2-1-3-static-content" class="header-anchor">#</a> 2.1.3. Static Content</h4> <p>By default, Spring Boot serves static content from a directory called <code>/static</code> (or <code>/public</code> or <code>/resources</code> or <code>/META-INF/resources</code>) in the classpath.
It uses the <code>ResourceWebHandler</code> from Spring WebFlux so that you can modify that behavior by adding your own <code>WebFluxConfigurer</code> and overriding the <code>addResourceHandlers</code> method.</p> <p>By default, resources are mapped on <code>/**</code>, but you can tune that by setting the <code>spring.webflux.static-path-pattern</code> property.
For instance, relocating all resources to <code>/resources/**</code> can be achieved as follows:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.webflux.static-path-pattern=/resources/**
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  webflux:
    static-path-pattern: &quot;/resources/**&quot;
</code></pre></div><p>You can also customize the static resource locations by using <code>spring.web.resources.static-locations</code>.
Doing so replaces the default values with a list of directory locations.
If you do so, the default welcome page detection switches to your custom locations.
So, if there is an <code>index.html</code> in any of your locations on startup, it is the home page of the application.</p> <p>In addition to the “standard” static resource locations listed earlier, a special case is made for <a href="https://www.webjars.org/" target="_blank" rel="noopener noreferrer">Webjars content<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.
Any resources with a path in <code>/webjars/**</code> are served from jar files if they are packaged in the Webjars format.</p> <table><thead><tr><th></th> <th>Spring WebFlux applications do not strictly depend on the servlet API, so they cannot be deployed as war files and do not use the <code>src/main/webapp</code> directory.</th></tr></thead> <tbody></tbody></table> <h4 id="_2-1-4-welcome-page"><a href="#_2-1-4-welcome-page" class="header-anchor">#</a> 2.1.4. Welcome Page</h4> <p>Spring Boot supports both static and templated welcome pages.
It first looks for an <code>index.html</code> file in the configured static content locations.
If one is not found, it then looks for an <code>index</code> template.
If either is found, it is automatically used as the welcome page of the application.</p> <h4 id="_2-1-5-template-engines"><a href="#_2-1-5-template-engines" class="header-anchor">#</a> 2.1.5. Template Engines</h4> <p>As well as REST web services, you can also use Spring WebFlux to serve dynamic HTML content.
Spring WebFlux supports a variety of templating technologies, including Thymeleaf, FreeMarker, and Mustache.</p> <p>Spring Boot includes auto-configuration support for the following templating engines:</p> <ul><li><p><a href="https://freemarker.apache.org/docs/" target="_blank" rel="noopener noreferrer">FreeMarker<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://www.thymeleaf.org" target="_blank" rel="noopener noreferrer">Thymeleaf<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://mustache.github.io/" target="_blank" rel="noopener noreferrer">Mustache<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li></ul> <p>When you use one of these templating engines with the default configuration, your templates are picked up automatically from <code>src/main/resources/templates</code>.</p> <h4 id="_2-1-6-error-handling"><a href="#_2-1-6-error-handling" class="header-anchor">#</a> 2.1.6. Error Handling</h4> <p>Spring Boot provides a <code>WebExceptionHandler</code> that handles all errors in a sensible way.
Its position in the processing order is immediately before the handlers provided by WebFlux, which are considered last.
For machine clients, it produces a JSON response with details of the error, the HTTP status, and the exception message.
For browser clients, there is a “whitelabel” error handler that renders the same data in HTML format.
You can also provide your own HTML templates to display errors (see the <a href="#web.reactive.webflux.error-handling.error-pages">next section</a>).</p> <p>The first step to customizing this feature often involves using the existing mechanism but replacing or augmenting the error contents.
For that, you can add a bean of type <code>ErrorAttributes</code>.</p> <p>To change the error handling behavior, you can implement <code>ErrorWebExceptionHandler</code> and register a bean definition of that type.
Because a <code>ErrorWebExceptionHandler</code> is quite low-level, Spring Boot also provides a convenient <code>AbstractErrorWebExceptionHandler</code> to let you handle errors in a WebFlux functional way, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>import reactor.core.publisher.Mono;

import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder;

@Component
public class MyErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler {

    public MyErrorWebExceptionHandler(ErrorAttributes errorAttributes, Resources resources,
            ApplicationContext applicationContext) {
        super(errorAttributes, resources, applicationContext);
    }

    @Override
    protected RouterFunction&lt;ServerResponse&gt; getRoutingFunction(ErrorAttributes errorAttributes) {
        return RouterFunctions.route(this::acceptsXml, this::handleErrorAsXml);
    }

    private boolean acceptsXml(ServerRequest request) {
        return request.headers().accept().contains(MediaType.APPLICATION_XML);
    }

    public Mono&lt;ServerResponse&gt; handleErrorAsXml(ServerRequest request) {
        BodyBuilder builder = ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR);
        // ... additional builder calls
        return builder.build();
    }

}

</code></pre></div><p>For a more complete picture, you can also subclass <code>DefaultErrorWebExceptionHandler</code> directly and override specific methods.</p> <p>In some cases, errors handled at the controller or handler function level are not recorded by the <a href="/en/spring-boot/actuator.html#actuator.metrics.supported.spring-webflux">metrics infrastructure</a>.
Applications can ensure that such exceptions are recorded with the request metrics by setting the handled exception as a request attribute:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.boot.web.reactive.error.ErrorAttributes;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.reactive.result.view.Rendering;
import org.springframework.web.server.ServerWebExchange;

@Controller
public class MyExceptionHandlingController {

    @GetMapping(&quot;/profile&quot;)
    public Rendering userProfile() {
        // ...
        throw new IllegalStateException();
    }

    @ExceptionHandler(IllegalStateException.class)
    public Rendering handleIllegalState(ServerWebExchange exchange, IllegalStateException exc) {
        exchange.getAttributes().putIfAbsent(ErrorAttributes.ERROR_ATTRIBUTE, exc);
        return Rendering.view(&quot;errorView&quot;).modelAttribute(&quot;message&quot;, exc.getMessage()).build();
    }

}

</code></pre></div><h5 id="custom-error-pages-2"><a href="#custom-error-pages-2" class="header-anchor">#</a> Custom Error Pages</h5> <p>If you want to display a custom HTML error page for a given status code, you can add a file to an <code>/error</code> directory.
Error pages can either be static HTML (that is, added under any of the static resource directories) or built with templates.
The name of the file should be the exact status code or a series mask.</p> <p>For example, to map <code>404</code> to a static HTML file, your directory structure would be as follows:</p> <div class="language- extra-class"><pre class="language-text"><code>src/
 +- main/
     +- java/
     |   + &lt;source code&gt;
     +- resources/
         +- public/
             +- error/
             |   +- 404.html
             +- &lt;other public assets&gt;
</code></pre></div><p>To map all <code>5xx</code> errors by using a Mustache template, your directory structure would be as follows:</p> <div class="language- extra-class"><pre class="language-text"><code>src/
 +- main/
     +- java/
     |   + &lt;source code&gt;
     +- resources/
         +- templates/
             +- error/
             |   +- 5xx.mustache
             +- &lt;other templates&gt;
</code></pre></div><h4 id="_2-1-7-web-filters"><a href="#_2-1-7-web-filters" class="header-anchor">#</a> 2.1.7. Web Filters</h4> <p>Spring WebFlux provides a <code>WebFilter</code> interface that can be implemented to filter HTTP request-response exchanges.<code>WebFilter</code> beans found in the application context will be automatically used to filter each exchange.</p> <p>Where the order of the filters is important they can implement <code>Ordered</code> or be annotated with <code>@Order</code>.
Spring Boot auto-configuration may configure web filters for you.
When it does so, the orders shown in the following table will be used:</p> <table><thead><tr><th>Web Filter</th> <th>Order</th></tr></thead> <tbody><tr><td><code>MetricsWebFilter</code></td> <td><code>Ordered.HIGHEST_PRECEDENCE + 1</code></td></tr> <tr><td><code>WebFilterChainProxy</code> (Spring Security)</td> <td><code>-100</code></td></tr> <tr><td><code>HttpTraceWebFilter</code></td> <td><code>Ordered.LOWEST_PRECEDENCE - 10</code></td></tr></tbody></table> <h3 id="_2-2-embedded-reactive-server-support"><a href="#_2-2-embedded-reactive-server-support" class="header-anchor">#</a> 2.2. Embedded Reactive Server Support</h3> <p>Spring Boot includes support for the following embedded reactive web servers: Reactor Netty, Tomcat, Jetty, and Undertow.
Most developers use the appropriate “Starter” to obtain a fully configured instance.
By default, the embedded server listens for HTTP requests on port 8080.</p> <h3 id="_2-3-reactive-server-resources-configuration"><a href="#_2-3-reactive-server-resources-configuration" class="header-anchor">#</a> 2.3. Reactive Server Resources Configuration</h3> <p>When auto-configuring a Reactor Netty or Jetty server, Spring Boot will create specific beans that will provide HTTP resources to the server instance: <code>ReactorResourceFactory</code> or <code>JettyResourceFactory</code>.</p> <p>By default, those resources will be also shared with the Reactor Netty and Jetty clients for optimal performances, given:</p> <ul><li><p>the same technology is used for server and client</p></li> <li><p>the client instance is built using the <code>WebClient.Builder</code> bean auto-configured by Spring Boot</p></li></ul> <p>Developers can override the resource configuration for Jetty and Reactor Netty by providing a custom <code>ReactorResourceFactory</code> or <code>JettyResourceFactory</code> bean - this will be applied to both clients and servers.</p> <p>You can learn more about the resource configuration on the client side in the <a href="/en/spring-boot/io.html#io.rest-client.webclient.runtime">WebClient Runtime section</a>.</p> <h2 id="_3-graceful-shutdown"><a href="#_3-graceful-shutdown" class="header-anchor">#</a> 3. Graceful Shutdown</h2> <p>Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and servlet-based web applications.
It occurs as part of closing the application context and is performed in the earliest phase of stopping <code>SmartLifecycle</code> beans.
This stop processing uses a timeout which provides a grace period during which existing requests will be allowed to complete but no new requests will be permitted.
The exact way in which new requests are not permitted varies depending on the web server that is being used.
Jetty, Reactor Netty, and Tomcat will stop accepting requests at the network layer.
Undertow will accept requests but respond immediately with a service unavailable (503) response.</p> <table><thead><tr><th></th> <th>Graceful shutdown with Tomcat requires Tomcat 9.0.33 or later.</th></tr></thead> <tbody></tbody></table> <p>To enable graceful shutdown, configure the <code>server.shutdown</code> property, as shown in the following example:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>server.shutdown=graceful
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>server:
  shutdown: &quot;graceful&quot;
</code></pre></div><p>To configure the timeout period, configure the <code>spring.lifecycle.timeout-per-shutdown-phase</code> property, as shown in the following example:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.lifecycle.timeout-per-shutdown-phase=20s
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  lifecycle:
    timeout-per-shutdown-phase: &quot;20s&quot;
</code></pre></div><table><thead><tr><th></th> <th>Using graceful shutdown with your IDE may not work properly if it does not send a proper <code>SIGTERM</code> signal.<br>See the documentation of your IDE for more details.</th></tr></thead> <tbody></tbody></table> <h2 id="_4-spring-security"><a href="#_4-spring-security" class="header-anchor">#</a> 4. Spring Security</h2> <p>If <a href="https://spring.io/projects/spring-security" target="_blank" rel="noopener noreferrer">Spring Security<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> is on the classpath, then web applications are secured by default.
Spring Boot relies on Spring Security’s content-negotiation strategy to determine whether to use <code>httpBasic</code> or <code>formLogin</code>.
To add method-level security to a web application, you can also add <code>@EnableGlobalMethodSecurity</code> with your desired settings.
Additional information can be found in the <a href="https://docs.spring.io/spring-security/reference/5.6.2/servlet/authorization/method-security.html" target="_blank" rel="noopener noreferrer">Spring Security Reference Guide<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>.</p> <p>The default <code>UserDetailsService</code> has a single user.
The user name is <code>user</code>, and the password is random and is printed at INFO level when the application starts, as shown in the following example:</p> <div class="language- extra-class"><pre class="language-text"><code>Using generated security password: 78fa095d-3f4c-48b1-ad50-e24c31d5cf35
</code></pre></div><table><thead><tr><th></th> <th>If you fine-tune your logging configuration, ensure that the <code>org.springframework.boot.autoconfigure.security</code> category is set to log <code>INFO</code>-level messages.<br>Otherwise, the default password is not printed.</th></tr></thead> <tbody></tbody></table> <p>You can change the username and password by providing a <code>spring.security.user.name</code> and <code>spring.security.user.password</code>.</p> <p>The basic features you get by default in a web application are:</p> <ul><li><p>A <code>UserDetailsService</code> (or <code>ReactiveUserDetailsService</code> in case of a WebFlux application) bean with in-memory store and a single user with a generated password (see <a href="https://docs.spring.io/spring-boot/docs/2.6.4/api/org/springframework/boot/autoconfigure/security/SecurityProperties.User.html" target="_blank" rel="noopener noreferrer"><code>SecurityProperties.User</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> for the properties of the user).</p></li> <li><p>Form-based login or HTTP Basic security (depending on the <code>Accept</code> header in the request) for the entire application (including actuator endpoints if actuator is on the classpath).</p></li> <li><p>A <code>DefaultAuthenticationEventPublisher</code> for publishing authentication events.</p></li></ul> <p>You can provide a different <code>AuthenticationEventPublisher</code> by adding a bean for it.</p> <h3 id="_4-1-mvc-security"><a href="#_4-1-mvc-security" class="header-anchor">#</a> 4.1. MVC Security</h3> <p>The default security configuration is implemented in <code>SecurityAutoConfiguration</code> and <code>UserDetailsServiceAutoConfiguration</code>.<code>SecurityAutoConfiguration</code> imports <code>SpringBootWebSecurityConfiguration</code> for web security and <code>UserDetailsServiceAutoConfiguration</code> configures authentication, which is also relevant in non-web applications.
To switch off the default web application security configuration completely or to combine multiple Spring Security components such as OAuth2 Client and Resource Server, add a bean of type <code>SecurityFilterChain</code> (doing so does not disable the <code>UserDetailsService</code> configuration or Actuator’s security).</p> <p>To also switch off the <code>UserDetailsService</code> configuration, you can add a bean of type <code>UserDetailsService</code>, <code>AuthenticationProvider</code>, or <code>AuthenticationManager</code>.</p> <p>Access rules can be overridden by adding a custom <code>SecurityFilterChain</code> or <code>WebSecurityConfigurerAdapter</code> bean.
Spring Boot provides convenience methods that can be used to override access rules for actuator endpoints and static resources.<code>EndpointRequest</code> can be used to create a <code>RequestMatcher</code> that is based on the <code>management.endpoints.web.base-path</code> property.<code>PathRequest</code> can be used to create a <code>RequestMatcher</code> for resources in commonly used locations.</p> <h3 id="_4-2-webflux-security"><a href="#_4-2-webflux-security" class="header-anchor">#</a> 4.2. WebFlux Security</h3> <p>Similar to Spring MVC applications, you can secure your WebFlux applications by adding the <code>spring-boot-starter-security</code> dependency.
The default security configuration is implemented in <code>ReactiveSecurityAutoConfiguration</code> and <code>UserDetailsServiceAutoConfiguration</code>.<code>ReactiveSecurityAutoConfiguration</code> imports <code>WebFluxSecurityConfiguration</code> for web security and <code>UserDetailsServiceAutoConfiguration</code> configures authentication, which is also relevant in non-web applications.
To switch off the default web application security configuration completely, you can add a bean of type <code>WebFilterChainProxy</code> (doing so does not disable the <code>UserDetailsService</code> configuration or Actuator’s security).</p> <p>To also switch off the <code>UserDetailsService</code> configuration, you can add a bean of type <code>ReactiveUserDetailsService</code> or <code>ReactiveAuthenticationManager</code>.</p> <p>Access rules and the use of multiple Spring Security components such as OAuth 2 Client and Resource Server can be configured by adding a custom <code>SecurityWebFilterChain</code> bean.
Spring Boot provides convenience methods that can be used to override access rules for actuator endpoints and static resources.<code>EndpointRequest</code> can be used to create a <code>ServerWebExchangeMatcher</code> that is based on the <code>management.endpoints.web.base-path</code> property.</p> <p><code>PathRequest</code> can be used to create a <code>ServerWebExchangeMatcher</code> for resources in commonly used locations.</p> <p>For example, you can customize your security configuration by adding something like:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.boot.autoconfigure.security.reactive.PathRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;

@Configuration(proxyBeanMethods = false)
public class MyWebFluxSecurityConfiguration {

    @Bean
    public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
        http.authorizeExchange((spec) -&gt; {
            spec.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll();
            spec.pathMatchers(&quot;/foo&quot;, &quot;/bar&quot;).authenticated();
        });
        http.formLogin();
        return http.build();
    }

}

</code></pre></div><h3 id="_4-3-oauth2"><a href="#_4-3-oauth2" class="header-anchor">#</a> 4.3. OAuth2</h3> <p><a href="https://oauth.net/2/" target="_blank" rel="noopener noreferrer">OAuth2<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> is a widely used authorization framework that is supported by Spring.</p> <h4 id="_4-3-1-client"><a href="#_4-3-1-client" class="header-anchor">#</a> 4.3.1. Client</h4> <p>If you have <code>spring-security-oauth2-client</code> on your classpath, you can take advantage of some auto-configuration to set up an OAuth2/Open ID Connect clients.
This configuration makes use of the properties under <code>OAuth2ClientProperties</code>.
The same properties are applicable to both servlet and reactive applications.</p> <p>You can register multiple OAuth2 clients and providers under the <code>spring.security.oauth2.client</code> prefix, as shown in the following example:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.security.oauth2.client.registration.my-client-1.client-id=abcd
spring.security.oauth2.client.registration.my-client-1.client-secret=password
spring.security.oauth2.client.registration.my-client-1.client-name=Client for user scope
spring.security.oauth2.client.registration.my-client-1.provider=my-oauth-provider
spring.security.oauth2.client.registration.my-client-1.scope=user
spring.security.oauth2.client.registration.my-client-1.redirect-uri=https://my-redirect-uri.com
spring.security.oauth2.client.registration.my-client-1.client-authentication-method=basic
spring.security.oauth2.client.registration.my-client-1.authorization-grant-type=authorization-code

spring.security.oauth2.client.registration.my-client-2.client-id=abcd
spring.security.oauth2.client.registration.my-client-2.client-secret=password
spring.security.oauth2.client.registration.my-client-2.client-name=Client for email scope
spring.security.oauth2.client.registration.my-client-2.provider=my-oauth-provider
spring.security.oauth2.client.registration.my-client-2.scope=email
spring.security.oauth2.client.registration.my-client-2.redirect-uri=https://my-redirect-uri.com
spring.security.oauth2.client.registration.my-client-2.client-authentication-method=basic
spring.security.oauth2.client.registration.my-client-2.authorization-grant-type=authorization_code

spring.security.oauth2.client.provider.my-oauth-provider.authorization-uri=https://my-auth-server/oauth/authorize
spring.security.oauth2.client.provider.my-oauth-provider.token-uri=https://my-auth-server/oauth/token
spring.security.oauth2.client.provider.my-oauth-provider.user-info-uri=https://my-auth-server/userinfo
spring.security.oauth2.client.provider.my-oauth-provider.user-info-authentication-method=header
spring.security.oauth2.client.provider.my-oauth-provider.jwk-set-uri=https://my-auth-server/token_keys
spring.security.oauth2.client.provider.my-oauth-provider.user-name-attribute=name
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  security:
    oauth2:
      client:
        registration:
          my-client-1:
            client-id: &quot;abcd&quot;
            client-secret: &quot;password&quot;
            client-name: &quot;Client for user scope&quot;
            provider: &quot;my-oauth-provider&quot;
            scope: &quot;user&quot;
            redirect-uri: &quot;https://my-redirect-uri.com&quot;
            client-authentication-method: &quot;basic&quot;
            authorization-grant-type: &quot;authorization-code&quot;

          my-client-2:
            client-id: &quot;abcd&quot;
            client-secret: &quot;password&quot;
            client-name: &quot;Client for email scope&quot;
            provider: &quot;my-oauth-provider&quot;
            scope: &quot;email&quot;
            redirect-uri: &quot;https://my-redirect-uri.com&quot;
            client-authentication-method: &quot;basic&quot;
            authorization-grant-type: &quot;authorization_code&quot;

        provider:
          my-oauth-provider:
            authorization-uri: &quot;https://my-auth-server/oauth/authorize&quot;
            token-uri: &quot;https://my-auth-server/oauth/token&quot;
            user-info-uri: &quot;https://my-auth-server/userinfo&quot;
            user-info-authentication-method: &quot;header&quot;
            jwk-set-uri: &quot;https://my-auth-server/token_keys&quot;
            user-name-attribute: &quot;name&quot;
</code></pre></div><p>For OpenID Connect providers that support <a href="https://openid.net/specs/openid-connect-discovery-1_0.html" target="_blank" rel="noopener noreferrer">OpenID Connect discovery<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>, the configuration can be further simplified.
The provider needs to be configured with an <code>issuer-uri</code> which is the URI that the it asserts as its Issuer Identifier.
For example, if the <code>issuer-uri</code> provided is &quot;https://example.com&quot;, then an <code>OpenID Provider Configuration Request</code> will be made to &quot;https://example.com/.well-known/openid-configuration&quot;.
The result is expected to be an <code>OpenID Provider Configuration Response</code>.
The following example shows how an OpenID Connect Provider can be configured with the <code>issuer-uri</code>:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.security.oauth2.client.provider.oidc-provider.issuer-uri=https://dev-123456.oktapreview.com/oauth2/default/
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  security:
    oauth2:
      client:
        provider:
          oidc-provider:
            issuer-uri: &quot;https://dev-123456.oktapreview.com/oauth2/default/&quot;
</code></pre></div><p>By default, Spring Security’s <code>OAuth2LoginAuthenticationFilter</code> only processes URLs matching <code>/login/oauth2/code/*</code>.
If you want to customize the <code>redirect-uri</code> to use a different pattern, you need to provide configuration to process that custom pattern.
For example, for servlet applications, you can add your own <code>SecurityFilterChain</code> that resembles the following:</p> <div class="language- extra-class"><pre class="language-text"><code>import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

@Configuration(proxyBeanMethods = false)
public class MyOAuthClientConfiguration {

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().authenticated();
        http.oauth2Login().redirectionEndpoint().baseUri(&quot;custom-callback&quot;);
        return http.build();
    }

}

</code></pre></div><table><thead><tr><th></th> <th>Spring Boot auto-configures an <code>InMemoryOAuth2AuthorizedClientService</code> which is used by Spring Security for the management of client registrations.<br>The <code>InMemoryOAuth2AuthorizedClientService</code> has limited capabilities and we recommend using it only for development environments.<br>For production environments, consider using a <code>JdbcOAuth2AuthorizedClientService</code> or creating your own implementation of <code>OAuth2AuthorizedClientService</code>.</th></tr></thead> <tbody></tbody></table> <h5 id="oauth2-client-registration-for-common-providers"><a href="#oauth2-client-registration-for-common-providers" class="header-anchor">#</a> OAuth2 client registration for common providers</h5> <p>For common OAuth2 and OpenID providers, including Google, Github, Facebook, and Okta, we provide a set of provider defaults (<code>google</code>, <code>github</code>, <code>facebook</code>, and <code>okta</code>, respectively).</p> <p>If you do not need to customize these providers, you can set the <code>provider</code> attribute to the one for which you need to infer defaults.
Also, if the key for the client registration matches a default supported provider, Spring Boot infers that as well.</p> <p>In other words, the two configurations in the following example use the Google provider:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.security.oauth2.client.registration.my-client.client-id=abcd
spring.security.oauth2.client.registration.my-client.client-secret=password
spring.security.oauth2.client.registration.my-client.provider=google
spring.security.oauth2.client.registration.google.client-id=abcd
spring.security.oauth2.client.registration.google.client-secret=password
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  security:
    oauth2:
      client:
        registration:
          my-client:
            client-id: &quot;abcd&quot;
            client-secret: &quot;password&quot;
            provider: &quot;google&quot;
          google:
            client-id: &quot;abcd&quot;
            client-secret: &quot;password&quot;
</code></pre></div><h4 id="_4-3-2-resource-server"><a href="#_4-3-2-resource-server" class="header-anchor">#</a> 4.3.2. Resource Server</h4> <p>If you have <code>spring-security-oauth2-resource-server</code> on your classpath, Spring Boot can set up an OAuth2 Resource Server.
For JWT configuration, a JWK Set URI or OIDC Issuer URI needs to be specified, as shown in the following examples:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://example.com/oauth2/default/v1/keys
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          jwk-set-uri: &quot;https://example.com/oauth2/default/v1/keys&quot;
</code></pre></div><p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.security.oauth2.resourceserver.jwt.issuer-uri=https://dev-123456.oktapreview.com/oauth2/default/
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          issuer-uri: &quot;https://dev-123456.oktapreview.com/oauth2/default/&quot;
</code></pre></div><table><thead><tr><th></th> <th>If the authorization server does not support a JWK Set URI, you can configure the resource server with the Public Key used for verifying the signature of the JWT.<br>This can be done using the <code>spring.security.oauth2.resourceserver.jwt.public-key-location</code> property, where the value needs to point to a file containing the public key in the PEM-encoded x509 format.</th></tr></thead> <tbody></tbody></table> <p>The same properties are applicable for both servlet and reactive applications.</p> <p>Alternatively, you can define your own <code>JwtDecoder</code> bean for servlet applications or a <code>ReactiveJwtDecoder</code> for reactive applications.</p> <p>In cases where opaque tokens are used instead of JWTs, you can configure the following properties to validate tokens through introspection:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.security.oauth2.resourceserver.opaquetoken.introspection-uri=https://example.com/check-token
spring.security.oauth2.resourceserver.opaquetoken.client-id=my-client-id
spring.security.oauth2.resourceserver.opaquetoken.client-secret=my-client-secret
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  security:
    oauth2:
      resourceserver:
        opaquetoken:
          introspection-uri: &quot;https://example.com/check-token&quot;
          client-id: &quot;my-client-id&quot;
          client-secret: &quot;my-client-secret&quot;
</code></pre></div><p>Again, the same properties are applicable for both servlet and reactive applications.</p> <p>Alternatively, you can define your own <code>OpaqueTokenIntrospector</code> bean for servlet applications or a <code>ReactiveOpaqueTokenIntrospector</code> for reactive applications.</p> <h4 id="_4-3-3-authorization-server"><a href="#_4-3-3-authorization-server" class="header-anchor">#</a> 4.3.3. Authorization Server</h4> <p>Currently, Spring Security does not provide support for implementing an OAuth 2.0 Authorization Server.
However, this functionality is available from the <a href="https://spring.io/projects/spring-security-oauth" target="_blank" rel="noopener noreferrer">Spring Security OAuth<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> project, which will eventually be superseded by Spring Security completely.
Until then, you can use the <code>spring-security-oauth2-autoconfigure</code> module to easily set up an OAuth 2.0 authorization server; see its <a href="https://docs.spring.io/spring-security-oauth2-boot/" target="_blank" rel="noopener noreferrer">documentation<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> for instructions.</p> <h3 id="_4-4-saml-2-0"><a href="#_4-4-saml-2-0" class="header-anchor">#</a> 4.4. SAML 2.0</h3> <h4 id="_4-4-1-relying-party"><a href="#_4-4-1-relying-party" class="header-anchor">#</a> 4.4.1. Relying Party</h4> <p>If you have <code>spring-security-saml2-service-provider</code> on your classpath, you can take advantage of some auto-configuration to set up a SAML 2.0 Relying Party.
This configuration makes use of the properties under <code>Saml2RelyingPartyProperties</code>.</p> <p>A relying party registration represents a paired configuration between an Identity Provider, IDP, and a Service Provider, SP.
You can register multiple relying parties under the <code>spring.security.saml2.relyingparty</code> prefix, as shown in the following example:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.security.saml2.relyingparty.registration.my-relying-party1.signing.credentials[0].private-key-location=path-to-private-key
spring.security.saml2.relyingparty.registration.my-relying-party1.signing.credentials[0].certificate-location=path-to-certificate
spring.security.saml2.relyingparty.registration.my-relying-party1.decryption.credentials[0].private-key-location=path-to-private-key
spring.security.saml2.relyingparty.registration.my-relying-party1.decryption.credentials[0].certificate-location=path-to-certificate
spring.security.saml2.relyingparty.registration.my-relying-party1.identityprovider.verification.credentials[0].certificate-location=path-to-verification-cert
spring.security.saml2.relyingparty.registration.my-relying-party1.identityprovider.entity-id=remote-idp-entity-id1
spring.security.saml2.relyingparty.registration.my-relying-party1.identityprovider.sso-url=https://remoteidp1.sso.url

spring.security.saml2.relyingparty.registration.my-relying-party2.signing.credentials[0].private-key-location=path-to-private-key
spring.security.saml2.relyingparty.registration.my-relying-party2.signing.credentials[0].certificate-location=path-to-certificate
spring.security.saml2.relyingparty.registration.my-relying-party2.decryption.credentials[0].private-key-location=path-to-private-key
spring.security.saml2.relyingparty.registration.my-relying-party2.decryption.credentials[0].certificate-location=path-to-certificate
spring.security.saml2.relyingparty.registration.my-relying-party2.identityprovider.verification.credentials[0].certificate-location=path-to-other-verification-cert
spring.security.saml2.relyingparty.registration.my-relying-party2.identityprovider.entity-id=remote-idp-entity-id2
spring.security.saml2.relyingparty.registration.my-relying-party2.identityprovider.sso-url=https://remoteidp2.sso.url
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  security:
    saml2:
      relyingparty:
        registration:
          my-relying-party1:
            signing:
              credentials:
              - private-key-location: &quot;path-to-private-key&quot;
                certificate-location: &quot;path-to-certificate&quot;
            decryption:
              credentials:
              - private-key-location: &quot;path-to-private-key&quot;
                certificate-location: &quot;path-to-certificate&quot;
            identityprovider:
              verification:
                credentials:
                - certificate-location: &quot;path-to-verification-cert&quot;
              entity-id: &quot;remote-idp-entity-id1&quot;
              sso-url: &quot;https://remoteidp1.sso.url&quot;

          my-relying-party2:
            signing:
              credentials:
              - private-key-location: &quot;path-to-private-key&quot;
                certificate-location: &quot;path-to-certificate&quot;
            decryption:
              credentials:
              - private-key-location: &quot;path-to-private-key&quot;
                certificate-location: &quot;path-to-certificate&quot;
            identityprovider:
              verification:
                credentials:
                - certificate-location: &quot;path-to-other-verification-cert&quot;
              entity-id: &quot;remote-idp-entity-id2&quot;
              sso-url: &quot;https://remoteidp2.sso.url&quot;
</code></pre></div><h2 id="_5-spring-session"><a href="#_5-spring-session" class="header-anchor">#</a> 5. Spring Session</h2> <p>Spring Boot provides <a href="https://spring.io/projects/spring-session" target="_blank" rel="noopener noreferrer">Spring Session<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> auto-configuration for a wide range of data stores.
When building a servlet web application, the following stores can be auto-configured:</p> <ul><li><p>JDBC</p></li> <li><p>Redis</p></li> <li><p>Hazelcast</p></li> <li><p>MongoDB</p></li></ul> <p>The servlet auto-configuration replaces the need to use <code>@Enable*HttpSession</code>.</p> <p>When building a reactive web application, the following stores can be auto-configured:</p> <ul><li><p>Redis</p></li> <li><p>MongoDB</p></li></ul> <p>The reactive auto-configuration replaces the need to use <code>@Enable*WebSession</code>.</p> <p>If a single Spring Session module is present on the classpath, Spring Boot uses that store implementation automatically.
If you have more than one implementation, you must choose the <a href="https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/StoreType.java" target="_blank" rel="noopener noreferrer"><code>StoreType</code><span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> that you wish to use to store the sessions.
For instance, to use JDBC as the back-end store, you can configure your application as follows:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.session.store-type=jdbc
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  session:
    store-type: &quot;jdbc&quot;
</code></pre></div><table><thead><tr><th></th> <th>You can disable Spring Session by setting the <code>store-type</code> to <code>none</code>.</th></tr></thead> <tbody></tbody></table> <p>Each store has specific additional settings.
For instance, it is possible to customize the name of the table for the JDBC store, as shown in the following example:</p> <p>Properties</p> <div class="language- extra-class"><pre class="language-text"><code>spring.session.jdbc.table-name=SESSIONS
</code></pre></div><p>Yaml</p> <div class="language- extra-class"><pre class="language-text"><code>spring:
  session:
    jdbc:
      table-name: &quot;SESSIONS&quot;
</code></pre></div><p>For setting the timeout of the session you can use the <code>spring.session.timeout</code> property.
If that property is not set with a servlet web application, the auto-configuration falls back to the value of <code>server.servlet.session.timeout</code>.</p> <p>You can take control over Spring Session’s configuration using <code>@Enable*HttpSession</code> (servlet) or <code>@Enable*WebSession</code> (reactive).
This will cause the auto-configuration to back off.
Spring Session can then be configured using the annotation’s attributes rather than the previously described configuration properties.</p> <h2 id="_6-spring-hateoas"><a href="#_6-spring-hateoas" class="header-anchor">#</a> 6. Spring HATEOAS</h2> <p>If you develop a RESTful API that makes use of hypermedia, Spring Boot provides auto-configuration for Spring HATEOAS that works well with most applications.
The auto-configuration replaces the need to use <code>@EnableHypermediaSupport</code> and registers a number of beans to ease building hypermedia-based applications, including a <code>LinkDiscoverers</code> (for client side support) and an <code>ObjectMapper</code> configured to correctly marshal responses into the desired representation.
The <code>ObjectMapper</code> is customized by setting the various <code>spring.jackson.*</code> properties or, if one exists, by a <code>Jackson2ObjectMapperBuilder</code> bean.</p> <p>You can take control of Spring HATEOAS’s configuration by using <code>@EnableHypermediaSupport</code>.
Note that doing so disables the <code>ObjectMapper</code> customization described earlier.</p> <table><thead><tr><th></th> <th><code>spring-boot-starter-hateoas</code> is specific to Spring MVC and should not be combined with Spring WebFlux.<br>In order to use Spring HATEOAS with Spring WebFlux, you can add a direct dependency on <code>org.springframework.hateoas:spring-hateoas</code> along with <code>spring-boot-starter-webflux</code>.</th></tr></thead> <tbody></tbody></table> <h2 id="_7-what-to-read-next"><a href="#_7-what-to-read-next" class="header-anchor">#</a> 7. What to Read Next</h2> <p>You should now have a good understanding of how to develop web applications with Spring Boot.
The next few sections describe how Spring Boot integrates with various <a href="/en/spring-boot/data.html#data">data technologies</a>, <a href="/en/spring-boot/messaging.html#messaging">messaging systems</a>, and other IO capabilities.
You can pick any of these based on your application’s needs.</p></div> <footer class="page-edit"><div class="edit-link"><a href="https://gitcode.net/dev-cloud/spring-docs/-/blob/master/docs/en/spring-boot/web.md" target="_blank" rel="noopener noreferrer">Edit this page on GitCode</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">Last Updated:</span> <span class="time">Thu Mar 17 2022 18:19:53 GMT+0800</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">

      <a href="/en/spring-boot/features.html" class="prev">
        Core Features
      </a></span> <span class="next"><a href="/en/spring-boot/data.html">
        Data
      </a>

    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.cf11b18e.js" defer></script><script src="/assets/js/3.50918073.js" defer></script><script src="/assets/js/4.cd4c3ff4.js" defer></script><script src="/assets/js/59.9079a4f5.js" defer></script>
  </body>
</html>