package com.keer.controller;
import com.keer.domain.Product; import com.keer.form.ProductForm; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod;
@Controller public class ProductController {
private static final Log logger = LogFactory.getLog(ProductController.class);
@RequestMapping("/product_input") public String inputProduct() { logger.info("inputProduct called"); return "ProductForm"; }
@RequestMapping(value = "/product_save", method = RequestMethod.POST) public String saveProduct(ProductForm productForm, Model model) { logger.info("saveProduct called"); Product product = new Product(); product.setName(productForm.getName()); product.setDescription((productForm.getDescription())); try { product.setPrice(Float.parseFloat(productForm.getPrice())); } catch (NumberFormatException e) { } model.addAttribute("product", product); return "ProductDetails"; }
}
|