⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displaycoursecontroller.java

📁 这是< Spring in Action 2005> 源码值得学习
💻 JAVA
字号:
package com.springinaction.training.mvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

import com.springinaction.training.model.Course;
import com.springinaction.training.service.CourseService;


public class DisplayCourseController 
    extends AbstractCommandController {

  public DisplayCourseController() {
    setCommandClass(DisplayCourseCommand.class);
  }
  
  protected ModelAndView handle(HttpServletRequest request,
      HttpServletResponse response, Object command, 
      BindException errors) throws Exception {

    DisplayCourseCommand displayCommand = 
        (DisplayCourseCommand) command;

    Course course = courseService.getCourse(displayCommand.getId());

    return new ModelAndView("courseDetail", "course", course);
  }
  
  // INJECTED
  private CourseService courseService;
  public void setCourseService(CourseService courseService) {
    this.courseService = courseService;
  }
}

⌨️ 快捷键说明

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