注解映射器适配器编写handle

springmvc 配置映射器与适配器

<mvc:annotation-driven/>使用MVC注解驱动加载 适配器与映射器

使用注解驱动的同时还会添加了好多MVC参数绑定方法比如json转换器

添加bean 

使用<bean class="springmvc.copy.Controller">来添加controller

但是单个controler添加比较麻烦

生产环境下我们使用以下组件来自动扫描controller坐在包目录下的所有controller类

<context:component-scan base-package="springmvc.copy"/>


编写 controler


package springmvc.copy;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

//使用注解标记这个类是控制器

@Controller

public class Controls {

//使用注解对url以及方法进行映射

@RequestMapping("index")

public ModelAndView quers() throws Exception {

ModelAndView andView = new ModelAndView();

andView.setViewName("newmod");

return andView;

}

}


视图解析器前缀后缀的配置



测试



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值