zoukankan      html  css  js  c++  java
  • 控制器Controller

    1)  org.springframework.web.servlet.mvc.ParameterizableViewController

    如果请求是/hello.action的请求路径,则直接跳转到/jsp/success.jsp页面,不经过程序员定义的控制器Action

      <!-- /index.action请求,直接转发到/index.jsp页面 -->
          <bean name="/index.action" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
                  <property name="viewName" value="/index.jsp"/>
          </bean>
          
          
         <!-- 注册视图解析器(view包)(框架) 
          <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                  <property name="prefix" value="/"/>
                  <property name="suffix" value=".jsp"/>
          </bean>
          -->

    2)  org.springframework.web.servlet.mvc.AbstractCommandController

    能够以实体的形式,收集客户端参数

    public class AdminAction extends AbstractCommandController{
        public AdminAction(){
            this.setCommandClass(Admin.class);
        }
        @Override
        protected ModelAndView handle(HttpServletRequest request,HttpServletResponse response, Object obj, BindException bindException)throws Exception {
            System.out.println("AdminAction::handle");
            ModelAndView modelAndView = new ModelAndView();
            Admin admin = null;
            if(obj instanceof Admin){
                admin = (Admin) obj;
            }
            modelAndView.addObject("username",admin.getUsername());
            modelAndView.addObject("gender",admin.getGender());
            modelAndView.addObject("hiredate",admin.getHiredate());
            modelAndView.setViewName("/jsp/success.jsp");
            return modelAndView;
        }
    }
     <!-- 请求处理类 -->
          <bean name="/add.action" class="loaderman.javaee.springmvc.controller.AdminAction">
          </bean>
          
          <!-- 映射器 -->
          <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
          </bean>
  • 相关阅读:
    SQL Server存储过程
    数据访问模式:数据并发控制(Data Concurrency Control)
    C#设计模式系列:观察者模式(Observer)
    awk内置字符串函数 awk 格式化输出
    使用MegaCli和Smartctl获取普通磁盘
    Shell之date用法
    linux 系统下查看raid信息,以及磁盘信息
    linux下proc里关于磁盘性能的参数
    hdparm测试硬盘性能
    查看现有运行的linux服务器有多少内存条
  • 原文地址:https://www.cnblogs.com/loaderman/p/10063201.html
Copyright © 2011-2022 走看看