Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

spring mvc stuff #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.3.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
Copyright (c) 2016 IBM Corp.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">

<head>
<title>Liberty App Accelerator MVC Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h1 th:text="'Hello, ' + ${entity} + '!'"/>
<p>Welcome to your Liberty Spring MVC Application</p>
<p>Thanks for generating this project using the app accelerator.</p>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
limitations under the License.
-->
<div>
<h2>Spring Boot with Spring MVC</h2>
<p>Inside the project there is a application.springboot.web package
containing two classes:</p>
<h2>Spring Boot with Spring MVC and REST controllers</h2>
<p>Inside the project there is a application.springboot.web package containing these classes:</p>
<ul>
<li><code>SpringBootLibertyApplication</code>: The entry point for the SpringBoot application.</li>
<li><code>LibertyHelloController</code>: A Spring MVC endpoint which you can access at <a href="springbootweb">/springbootweb</a></li>
<li><code>LibertyMVController</code>: A Spring MVC endpoint which you can access at <a href="springbootmvc">/springbootmvc</a></li>
<li><code>LibertyRESTController</code>: A Spring REST endpoint which you can access at <a href="springbootrest">/springbootrest</a></li>
</ul>
<p>There is also a test class named <code>it.springboot.web.HelloControllerTest</code> that will test the Spring MVC endpoint to ensure it is working.</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package application.springboot.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LibertyMVController {

@RequestMapping("/springbootmvc")
public String greeting(@RequestParam(value="entity", required=false, defaultValue="World") String entity, Model model) {
model.addAttribute("entity", entity);
return "hello";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LibertyHelloController {
public class LibertyRestController {

@RequestMapping("/springbootweb")
@RequestMapping("/springbootrest")
public String hello() {
return "Hello from Spring Boot MVC running on Liberty!";
return "Hello from your Spring Boot Rest Controller running on Liberty!";
}

}