Java tutorial
/* * 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.MyHistory.Controller; //Imports import com.MyHistory.Service.Message.Response; import com.MyHistory.Service.ServiceCuenta; import java.util.Date; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; @Controller public class AdministratorController { @RequestMapping(value = "/FormularioAdministrador", method = RequestMethod.GET) public ModelAndView desplegarFormularioAdministrador() { System.out.println("admin Controller method:GET"); ModelAndView mv = new ModelAndView(); mv.setViewName("FormularioAdministrador"); return mv; } @RequestMapping(value = "/FormularioAdministrador", method = RequestMethod.POST) public ModelAndView registrarAdministrador(HttpServletRequest pRequest) { //Se crea el view a mostrar ModelAndView mv = new ModelAndView(); mv.setViewName("FormularioAdministrador"); //Se obtienen los parametros enviados desde el form String nombre = pRequest.getParameter("Nombre"); String apellido = pRequest.getParameter("Apellido"); String email = pRequest.getParameter("E-mail"); String nombre_usuario = pRequest.getParameter("Nombre Usuario"); String password = pRequest.getParameter("Password"); String dia = pRequest.getParameter("day"); String mes = pRequest.getParameter("month"); String ano = pRequest.getParameter("year"); FormateadorFecha fecha_format = new FormateadorFecha(); Date fecha_nacimiento = fecha_format.getFechaDateFormat(dia, mes, ano); //Se llama al servicio cuenta para obtener un mensaje de repuesta ServiceCuenta servicio_cuenta = new ServiceCuenta(); Response respuesta = servicio_cuenta.crearAdministrador(nombre, apellido, email, fecha_nacimiento, nombre_usuario, password); mv.addObject("respuesta", respuesta); return mv; } }