BAEL-1148 earth001@gmail.com - Mapped get method in controller / Removed resources (#3395)

* Sample code for BAEL-1148 - earth001@gmail.com

* Change tabs for spaces in non java files

* Change tabs for spaces in non java files

* Removed unnecessary argument

* BAEL-1148 earth001@gmail.com - Mapped get method in controller / Removed resources
This commit is contained in:
Juan Moreno 2018-01-11 23:30:31 -03:00 committed by KevinGilmore
parent d74c88299b
commit b360955e67
2 changed files with 11 additions and 21 deletions

View File

@ -3,28 +3,22 @@ package com.baeldung.controller;
import javax.servlet.http.PushBuilder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class PushController {
@RequestMapping(value = "/demoWithPush")
@GetMapping(path = "/demoWithPush")
public String demoWithPush(PushBuilder pushBuilder) {
if (null != pushBuilder) {
pushBuilder.path("resources/logo.png")
.addHeader("Content-Type", "image/png")
.push();
pushBuilder.path("resources/script.js")
.addHeader("Content-Type", "text/javascript")
.push();
pushBuilder.path("resources/style.css")
.addHeader("Content-Type", "text/css")
.push();
}
return "demo";
}
@RequestMapping(value = "/demoWithoutPush")
@GetMapping(path = "/demoWithoutPush")
public String demoWithoutPush() {
return "demo";
}

View File

@ -1,22 +1,18 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PushBuilder demo</title>
<link href="<c:url value="/resources/style.css"/>" rel="stylesheet" />
</head>
<body>
<span class="single-title">PushBuilder demo</span>
<br>
<img src="<c:url value="/resources/logo.png"/>" alt="Logo" height="126"
width="411">
<br>
<script type="text/javascript"
src="<c:url value="/resources/script.js"/>"></script>
<br> Go to
<a href="/spring-mvc-push/">index</a>
<span>PushBuilder demo</span>
<br>
<img src="<c:url value="/resources/logo.png"/>" alt="Logo"
height="126" width="411">
<br>
<br> Go to
<a href="/spring-mvc-push/">index</a>
</body>
</html>