Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Spring Basics Creating Controllers and Views Create a Controller to Handle HTTP Requests

WhiteLabel Error Page is coming

build.gradle plugins { id 'java' id 'idea' id 'eclipse' id 'org.springframework.boot' version '2.1.4.RELEASE' id "io.spring.dependency-management" version "1.0.7.RELEASE"

} group 'com.teamtreehouse' version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories { mavenCentral() }

dependencies { compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: '2.1.4.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.4.RELEASE' }

AppConfig.java package com.teamtreehouse.giflib;

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.ComponentScan;

@EnableAutoConfiguration @ComponentScan public class AppConfig { public static void main(String[] args){ //this method is from string boot library to run our application SpringApplication.run(AppConfig.class, args); } }

GifController.java package controller;

import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

@Controller public class GifController { @RequestMapping("/") @ResponseBody public String listGifs(){ return "List of all GIFs !"; }

}

application.properties server.port = 9999