Spring boot złe dane wejsciowe

0

Cześć
Staram się napisać mała aplikacje, mam pewien problem: w aplikacji należy wpisać String oraz int, przy wcisnieciu save tworzy sie nowy obiekt Money który jest zapisywany w bazie danych. problem polega na tym że nie wiem jak zablokować możliwość wpisania zamiast liczb np liter.
Może ktoś mi pomóc i dać jakąś poradę co nalezy zrobić ?

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta http-equiv="content-type" content="text/html charset=UTF-8"/>
    <title>Add Operation:</title>
</head>
<body>
<h1>New Operation</h1>
<div>
    <form th:object="${money}" th:action="@{save}" action="#" method="post">
        <input type="text" th:field="*{name}" class="form-controll" placeholder="name"/>
        <input type="text" th:field="*{amount}" class="form-controll" placeholder="amount"/>
        <input type="submit" class="btn btn-success" th:value="Save"/>
    </form>
</div>
</body>
</html>
@Controller
public class OperationsController {

    @Autowired
    private  MoneyRepository moneyRepository;




    @RequestMapping("/operations")
    public String index(Model model) {
        List<Money> operationsList = (List<Money>) moneyRepository.findAll();

        model.addAttribute("moneyOperations", operationsList);

        return "operations";
    }


    @RequestMapping(value = "add")
    public String addMoney(Model model) {
        model.addAttribute("money", new Money());
        return "addOperations";
    }

    @RequestMapping(value = "save", method = RequestMethod.POST)
    public String save(Money money) {
        moneyRepository.save(money);
        return "redirect:/operations/";
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    public String deleteOperation(@PathVariable("id") Money id) {
        moneyRepository.delete(id);
        return "redirect:/operations";
    }
    @RequestMapping("/deleteAll")
    public String deleteAll(){
        moneyRepository.deleteAll();
        return "redirect:/operations";
    }
}
@Data
@Entity
@Table(name = "operations")
public class Money {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private long id;

    @Column(name = "operation_name")
    private String name;
    @Column(name = "amount_spend")
    private int amount;

    public Money() {
    }

    public Money(String name, int amount) {
        this.name = name;
        this.amount = amount;
    }
}

1

chodzi o widok tak? To w input type zamiast text daj number :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1