GithubHelp home page GithubHelp logo

springbootdemo's Introduction

#######################################===SpringBoo前端视图及资源说明===##############################################

SpringBoot默认会在项目创建的一开始resources文件夹下自动创建static以及templates文件夹。
一般static下存放js以及css样式文件,templates存放html页面。
 
以上是默认会创建的文件夹以及其作用 ,下面我们来说一下转发和重定向的规律。 
首先static文件夹以及templates文件夹是受保护的,也就是说相当于你将文件放到了传统的ssh或ssm项目的WEB-INF下了。
所以也就是说这两个文件夹下的文件是无法通过url直接访问的,以至于在springmvc下使用重定向会报404。

那么希望直接访问的html或者css该如何存放呢?
方式一 
我们可以在resources下创建一个名为public的文件夹,顾名思义,放在此文件夹下的文件是共有的,可以直接通过url访问,当然也可以springmvc重定向访问啦。 
方法二 
在main下创建webapp文件夹,将文件放到此文件夹下,效果同上 
注!文件夹名字是固定的,起别的名字还是会报404或者无效 ,默认优先在webapp下寻找

#######################################################################################################################

springbootdemo's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.