createinstructorcontroller.java

来自「spring in action 源代码」· Java 代码 · 共 37 行

JAVA
37
字号
package com.springinaction.training.mvc;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.propertyeditors.CustomNumberEditor;import org.springframework.web.bind.ServletRequestDataBinder;import org.springframework.web.servlet.mvc.SimpleFormController;import com.springinaction.training.model.Instructor;import com.springinaction.training.service.InstructorService;public class CreateInstructorController extends SimpleFormController {  private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger      .getLogger(CreateInstructorController.class);    public CreateInstructorController() {    setCommandClass(Instructor.class);  }    protected void initBinder(HttpServletRequest request,      ServletRequestDataBinder binder) throws Exception {    CustomNumberEditor numberEditor = new CustomNumberEditor(Integer.class, true);    binder.registerCustomEditor(Integer.class, numberEditor);  }    protected void doSubmitAction(Object command) throws Exception {    instructorService.createInstructor((Instructor) command);  }    // COLLABORATORS  private InstructorService instructorService;  public void setInstructorService(InstructorService instructorService) {    this.instructorService = instructorService;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?