SpringBoot项目: WEB 与 Controller 的关系-【SB系列之009】 (基于008的资源)

这篇文章接着【SB系列之008】,讲讲 SpringBoot 项目中 WEB 页面和 Controller 之间的联系。

008 中提到的那些文件夹都是干嘛的?

  • JAVA 编译结果: class 文件会生成在 target 目录下 (你不用管)
  • resources 文件夹: 这里面的文件会原封不动地复制到最终项目中
  • test 文件夹: 顾名思义,测试用的,用来跑跑代码,看看结果对不对

Resources 文件夹重点详解

  1. public: 优先级最低,放一些大家都能访问的资源
  2. static: 放静态页面,比如图片,有时首页 (index.html) 也放这里
  3. templates: 放动态页面,只能通过 Controller 访问 (类似以前的 WEB-INF)

别看项目小,坑可不少。跟着做都能一次成功?那你真是学 JAVA 的好苗子!不用报班,刷刷 B 站视频,查查博客,就能秒杀一大波小白。

关键在于理解 resources 文件夹里的门道。多尝试,多试错,才能悟出其中的奥妙。

不怕别人比你聪明,就怕聪明的人比你还努力!

folder
SpringBoot项目中WEB与Controller的联系-【SB系列之009】008 的共用资源 预估大小:103个文件
file
mvnw.cmd 7KB
file
pom.xml 3KB
file
Unti41ApplicationTests.java 224B
file
application.properties 2B
file
userReg.html 377B
file
hello.html 159B
file
UserJSONController.java 420B
file
MainController.java 292B
file
Unti41Application.java 328B
file
User.java 191B
file
maven-wrapper.properties 220B
file
maven-wrapper.jar 50KB
file
MavenWrapperDownloader.java 5KB
file
.name 7B
file
uiDesigner.xml 9KB
file
Maven__org_junit_jupiter_junit_jupiter_params_5_7_2.xml 615B
file
Maven__org_hamcrest_hamcrest_2_2.xml 497B
file
Maven__org_junit_platform_junit_platform_commons_1_7_2.xml 633B
file
Maven__org_springframework_spring_aop_5_3_9.xml 553B
file
Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_4_RELEASE.xml 725B
file
Maven__org_xmlunit_xmlunit_core_2_8_2.xml 535B
file
Maven__org_springframework_boot_spring_boot_starter_test_2_5_3.xml 671B
file
Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_50.xml 625B
file
Maven__jakarta_xml_bind_jakarta_xml_bind_api_2_3_3.xml 611B
file
Maven__org_springframework_spring_test_5_3_9.xml 560B
file
Maven__org_attoparser_attoparser_2_0_5_RELEASE.xml 589B
file
Maven__org_junit_platform_junit_platform_engine_1_7_2.xml 626B
file
Maven__org_thymeleaf_thymeleaf_3_0_12_RELEASE.xml 585B
file
Maven__org_springframework_boot_spring_boot_2_5_3.xml 580B
file
Maven__net_minidev_json_smart_2_4_7.xml 521B
file
Maven__com_fasterxml_jackson_core_jackson_databind_2_12_4.xml 630B
file
Maven__org_ow2_asm_asm_9_1.xml 458B
file
Maven__org_junit_jupiter_junit_jupiter_5_7_2.xml 566B
file
Maven__net_bytebuddy_byte_buddy_agent_1_10_22.xml 585B
file
Maven__org_thymeleaf_thymeleaf_spring5_3_0_12_RELEASE.xml 641B
file
Maven__org_apache_logging_log4j_log4j_api_2_14_1.xml 573B
file
Maven__org_mockito_mockito_junit_jupiter_3_9_0.xml 598B
file
Maven__org_skyscreamer_jsonassert_1_5_0.xml 537B
file
Maven__org_assertj_assertj_core_3_19_0.xml 542B
file
Maven__org_apiguardian_apiguardian_api_1_1_0.xml 572B
file
Maven__org_junit_jupiter_junit_jupiter_api_5_7_2.xml 594B
file
Maven__org_springframework_spring_core_5_3_9.xml 560B
file
Maven__org_mockito_mockito_core_3_9_0.xml 535B
file
Maven__org_yaml_snakeyaml_1_28.xml 495B
file
Maven__org_springframework_boot_spring_boot_devtools_2_5_3.xml 643B
file
Maven__net_minidev_accessors_smart_2_4_7.xml 556B
file
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_12_4.xml 681B
file
Maven__org_springframework_boot_spring_boot_test_2_5_3.xml 615B
file
Maven__org_springframework_boot_spring_boot_starter_json_2_5_3.xml 671B
file
Maven__org_springframework_boot_spring_boot_starter_web_2_5_3.xml 664B
file
Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_12_4.xml 695B
file
Maven__org_springframework_boot_spring_boot_autoconfigure_2_5_3.xml 678B
file
Maven__jakarta_activation_jakarta_activation_api_1_2_2.xml 633B
file
Maven__ch_qos_logback_logback_core_1_2_4.xml 547B
file
Maven__com_fasterxml_jackson_core_jackson_annotations_2_12_4.xml 651B
file
Maven__com_jayway_jsonpath_json_path_2_5_0.xml 546B
file
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 700B
file
Maven__org_slf4j_jul_to_slf4j_1_7_32.xml 534B
file
Maven__org_apache_logging_log4j_log4j_to_slf4j_2_14_1.xml 608B
file
Maven__org_opentest4j_opentest4j_1_2_0.xml 533B
file
Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml 633B
file
Maven__org_objenesis_objenesis_3_2.xml 508B
file
Maven__net_bytebuddy_byte_buddy_1_10_22.xml 543B
file
Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_5_3.xml 706B
file
Maven__org_springframework_spring_context_5_3_9.xml 581B
file
Maven__org_webjars_jquery_3_6_0.xml 493B
file
Maven__com_fasterxml_jackson_core_jackson_core_2_12_4.xml 602B
file
Maven__org_apache_tomcat_embed_tomcat_embed_el_9_0_50.xml 611B
file
Maven__org_springframework_boot_spring_boot_starter_tomcat_2_5_3.xml 685B
file
Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_50.xml 660B
file
Maven__org_springframework_spring_webmvc_5_3_9.xml 574B
file
Maven__org_springframework_boot_spring_boot_starter_2_5_3.xml 636B
file
Maven__org_springframework_spring_beans_5_3_9.xml 567B
file
Maven__org_springframework_spring_jcl_5_3_9.xml 553B
file
Maven__org_springframework_boot_spring_boot_configuration_processor_2_5_3.xml 748B
file
Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_12_4.xml 736B
file
Maven__org_junit_jupiter_junit_jupiter_engine_5_7_2.xml 615B
file
Maven__org_springframework_spring_web_5_3_9.xml 553B
file
Maven__org_springframework_spring_expression_5_3_9.xml 602B
file
Maven__org_springframework_boot_spring_boot_starter_logging_2_5_3.xml 692B
file
Maven__org_slf4j_slf4j_api_1_7_32.xml 513B
file
Maven__org_unbescape_unbescape_1_1_6_RELEASE.xml 578B
file
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_5_3.xml 713B
file
Maven__ch_qos_logback_logback_classic_1_2_4.xml 568B
file
Maven__org_projectlombok_lombok_1_18_20.xml 531B
file
workspace.xml 43KB
file
misc.xml 820B
file
compiler.xml 626B
file
modules.xml 254B
file
encodings.xml 172B
file
kotlinc.xml 232B
file
application.properties 2B
file
userReg.html 377B
file
UserJSONController.class 682B
file
MainController.class 597B
file
Unti41Application.class 697B
file
User.class 3KB
file
hello.html 159B
file
Unti41ApplicationTests.class 525B
file
mvnw 10KB
file
unit4-2.iml 9KB
file
.gitignore 428B
file
2022黑马Java学习路线图.docx 338KB
...
rar 文件大小:398.45KB