Commit 795aff08 by Patryk Czarnik

@GetMapping i @PostMapping

parent ed78cacf
......@@ -2,19 +2,21 @@ package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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;
@Controller
public class Kalkulator {
@RequestMapping(path="/kalkulator", method=RequestMethod.GET)
@GetMapping("/kalkulator")
public String kalkulatorGet() {
// Obsługa metody GET - tylko wyświetlenie pustego formularza
return "kalkulator.html";
}
@RequestMapping(path="/kalkulator", method=RequestMethod.POST)
@PostMapping("/kalkulator")
public String kalkulatorPost(Model model, Integer liczba1, Integer liczba2, String operacja) {
// Obsługa metody POST - zakładamy, że parametry zostały przekazane (a jeśli nie, to będzie wyjątek).
Integer wynik = switch(operacja) {
......
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