I have followed all the tutorials, but still I have a problem that I can't get an object from a form to the controller using Spring MVC. What might be the case? I am using Thymeleaf to format my jsp pages.

<html xmlns:th="http://www.thymeleaf.org">
  <title>Getting Started: Handing Form Submission</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
${priceIncrease.getMessage()} ddd
<form action="" th:action="@{/increaseprice}" th:object="${priceIncrease}" method="post">
    <input type="text" th:field="*{message}" />
  <p><input type="submit" value="Submit" />

package com.springapp.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import store.service.PriceIncrease;

import org.apache.commons.logging.*;

public class PriceIncreaseFormController{

    protected final Log logger = LogFactory.getLog(getClass());

    @RequestMapping(value="/increaseprice.html", method = RequestMethod.POST)
    public String increasePrice(@ModelAttribute("priceIncrease") PriceIncrease priceIncrease){
        int increase = priceIncrease.getPercentage();
        logger.info("Percentage " + increase);
        logger.info("Message " + priceIncrease.getMessage());
        return "priceincrease";

    @RequestMapping(value="increaseprice.html", method = RequestMethod.GET)
    public String showIncreasePrice(Model model){
        PriceIncrease priceIncrease = new PriceIncrease("testmessage");
        model.addAttribute("priceIncrease", priceIncrease);

        return "priceincrease";

package store.service;

 * Created by kert on 7/9/15.
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PriceIncrease {
    protected final Log logger = LogFactory.getLog(getClass());

    private int percentage;
    private String message;

    public PriceIncrease(){


    public PriceIncrease(String message){
        this.message = message;

    public void setPercentage(int i){
        percentage = i;
        logger.info("Percentage set to " + i);

    public int getPercentage(){
        return  percentage;

    public String getMessage(){
        return this.message;

    public void setMessage( String message ){
        this.message = message;
1 Year
Discussion Span
Last Post by stultuske
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.