com.spring.tutorial.mvc.controller.SampleController.java Source code

Java tutorial

Introduction

Here is the source code for com.spring.tutorial.mvc.controller.SampleController.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring.tutorial.mvc.controller;

import com.spring.tutorial.mvc.beans.Foo;
import java.math.BigDecimal;
import java.util.Date;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("mvc")
public class SampleController {

    @RequestMapping("conversion")
    public String conversionSample(Model model) {
        Foo foo = new Foo("This is a bar");
        foo.setDate(new Date());
        foo.setDecimal(BigDecimal.valueOf(10558.45));
        model.addAttribute(foo);
        return "views/conversion";
    }
}