Giter Site home page Giter Site logo

springboot-jsp's Introduction

springboot-jsp

An example of Spring Boot application that uses an embedded tomcat and jsp.

Use JSP in your current Spring Boot project

  1. Add required dependencies:
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency><!-- Optional, use this only when you need spring security taglibs -->
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
</dependency>
  1. Add view prefixes in application properties (yaml example below)
spring:
  mvc:
    view:
      prefix: /WEB-INF/
      suffix: .jsp
  1. Configure view resolver:
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    @Value("${spring.mvc.view.prefix}")
    private String prefix;

    @Value("${spring.mvc.view.suffix}")
    private String suffix;

    /**
     * Configures view resolver for jsp views.
     */
    @Bean
    public InternalResourceViewResolver setupViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix(prefix);
        resolver.setSuffix(suffix);
        resolver.setViewClass(JstlView.class);
        return resolver;
    }
}
  1. Create jsp views in src/main/webapp/WEB-INF/ directory.

How to run this application

Extract project

Extract project in some location on your local machine.

Build application

Go to the project location:

cd /path/to/project/location

Build project with maven by executing command:

./mvnw clean install

Start application

Execute .jar file:

java -jar target/rxjava2-simultaneous-tasks-0.0.1-SNAPSHOT.jar

By default application should be accessible under localhost:8080.

There is one endpoint which returns simple jsp home page.

springboot-jsp's People

Contributors

lukaszwojtaszektti avatar luwojtaszek avatar

Stargazers

 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.