Commit 7b3a1080 by Patryk Czarnik

Get / Post

parent cca6875c
package org.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class RootController {
// @RequestMapping - obsługuje wszystkie typy zapytań (GET, POST, PUT, ...) pod podanym adresem
@RequestMapping("/")
@ResponseBody
public String stronaGlowna() {
return "Witaj w Springu";
return "<h1>Witaj w Springu</h1><p>Lalala, to jest dalsza część</p>";
}
// obsługa tylko zapytań typu GET
// konfiguracja w starym stylu oraz w nowym stylu
// @RequestMapping(path="/hello", method= RequestMethod.GET)
// @RequestMapping(path="/hello", method= {RequestMethod.GET, RequestMethod.POST})
@GetMapping("/hello")
@ResponseBody
public String hello() {
return "Hello world";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment