『 컨트롤러 클래스 작성

​<코드작성>

​@Controller
@RequestMapping("/test/form2")
public class Form2Controller {
   
    // ①command 초기 객체 취득
    @ModelAttribute("sampleCommand")
    public SampleCommand createInitCommand() {
        SampleCommand command = new SampleCommand();
 return command;    
     }
   
    // ②초기값 설정
    @RequestMapping(method=RequestMethod.GET)
    public void setupForm(Model model) {
       
        SampleCommand command = createInitCommand();
        command.setAge(1);
        model.addAttribute("sampleCommand", command);
       
    }


 

 

 


+ Recent posts