Giter Club home page Giter Club logo

xyz90161

範例使用: JDK 1.8
tomcat 8.5
spring boot 2.0.0
描述:
在spring boot 2.0.0的框架下使用gradle建置並且能夠返回jsp頁面,你可以使用servlet的方式或者controller的方式

eclipse設定:
將專案import至eclipse中選擇gradle(STS) project:
image

選擇build model:
image

在properties中設定deployment Assembly中 Add Source:/src/main/webapp   Deploy Path:/
將webapp下面的目錄WEB-INF佈署到root diectory中
image

gradle設定:
加入下列compile才有辦法能夠在WEB-INF目錄中返回jsp頁面
compile('jstl:jstl:1.2')
compile('org.apache.tomcat.embed:tomcat-embed-jasper')

在gradle中加入此行就能夠將spring boot全部加入lib中
compile("org.springframework.boot:spring-boot-starter-web")

lombok可以讓annotation能夠支援@Data或@Log等
compile('org.projectlombok:lombok:1.16.20')

此行讓tomcat啟用時能夠啟動spring boot
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')

在瀏覽器輸入URL測試controller是否返回頁面:
http://localhost:8060/${projectName}/hello

在瀏覽器輸入URL測試servlet是否返回頁面:
http://localhost:8060/${projectName}/index

返回Hello World!文字,可以測試controller是否正常工作 http://localhost:8060/${projectName}/helloWorld

注意在eclipse測試時可以在eclipse的 ${workspace}${project}.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps 中查看目錄結構,以便調試。

xyz90161's Projects

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.