Created
May 5, 2019 10:45
-
-
Save darbyluv2code/cd9cd2c01c4542d46e02c4e1f22fe678 to your computer and use it in GitHub Desktop.
duplicate form field names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.luv2code.springdemo.mvc; | |
| import java.util.Arrays; | |
| import java.util.Map; | |
| import javax.servlet.http.HttpServletRequest; | |
| import org.springframework.stereotype.Controller; | |
| import org.springframework.ui.Model; | |
| import org.springframework.web.bind.annotation.ModelAttribute; | |
| import org.springframework.web.bind.annotation.RequestMapping; | |
| @Controller | |
| @RequestMapping("/student") | |
| public class StudentController { | |
| @RequestMapping("/showForm") | |
| public String showForm(Model theModel) { | |
| theModel.addAttribute("student", new Student()); | |
| return "student-form"; | |
| } | |
| @RequestMapping("/processForm") | |
| public String processForm(@ModelAttribute("student") Student theStudent, HttpServletRequest request) { | |
| System.out.println("List of parameters from HttpServletRequest"); | |
| Map<String, String[]> parameterMap = request.getParameterMap(); | |
| for (String tempParamName : parameterMap.keySet()) { | |
| String[] tempParamVal = parameterMap.get(tempParamName); | |
| System.out.println(tempParamName + " = " + Arrays.asList(tempParamVal)); | |
| } | |
| System.out.println("\n\n"); | |
| System.out.println("Student Details : " + theStudent); | |
| return "student-confirmation"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment