spring mvc annotation总结
来源:互联网 发布:网络带来的好处 编辑:程序博客网 时间:2024/06/08 01:51
<context:annotation-config/>
他的作用是式地向
AutowiredAnnotationBeanP
注册这4个
<context:component-scan
<mvc:argument-resolvers>
允许注册实现了WebArgumentResolver接口的bean,来对handlerMethod中的用户自定义的参数或annotation进行解析
<mvc:annotation-driven validator="validator"><mvc:argument-resolvers><beanclass="net.zhepu.web.handlers.argumentHandler.MyCustomerWebArgumentHandler" /></mvc:argument-resolvers></mvc:annotation-driven>
对应的java
public class MyCustomerWebArgumentHandler implements WebArgumentResolver {@Overridepublic Object resolveArgument(MethodParameter methodParameter,NativeWebRequest webRequest) throws Exception {if (methodParameter.getParameterType().equals(MyArgument.class)) {MyArgument argu = new MyArgument();argu.setArgumentName("winzip");argu.setArgumentValue("123456");return argu;}return UNRESOLVED;}}
@Controller、@Service 以及 @Repository 和 @Component 注解的作用是等价的:将一个类成为 Spring 容器的 Bean。
如果是没有用@Service之前,是用xml,写个bean。至于以前xml中需要注入Dao,现在则不需要了。
由于 Spring MVC 的 Controller 必须事先是一个 Bean,所以 @Controller 注解是不可缺少的。
@RequestMapping(value = "/image",method = RequestMethod.GET) ModelAndView index(@RequestParam(value="page",required=false, defaultValue="1") int page)@RequestParam注解可以用来提取名为“number”的String类型的参数,并将之作为输入参数传入。
@RequestMapping(value = "/image/{id}", method = RequestMethod.GET) ModelAndView toEdit(@PathVariable long id){id}在这个请求的URL里就是个变量,可以使用@PathVariable来获取
@PathVariable和@RequestParam的区别就在于:@RequestParam用来获得静态的URL请求入参数
- spring mvc annotation总结
- [Spring MVC] - Annotation验证
- [Spring MVC] - Annotation验证
- [Spring MVC] - Annotation验证
- Spring MVC annotation (一)
- Spring MVC annotation (二)
- spring mvc annotation
- Spring mvc:annotation-driven
- Spring MVC annotation
- Spring参考手册 mvc:annotation-driven
- Spring MVC 3 -- annotation 配置
- spring mvc annotation 的例子
- Spring MVC MultiActionController annotation example
- Spring MVC MultiActionController annotation example
- spring mvc <mvc:annotation-driver/>详解
- 【Spring MVC】<mvc:annotation-driven/>详解
- Spring MVC 中关于 mvc:annotation-driven
- spring mvc 之mvc:annotation-driven
- sqlite简单笔记
- pbs使用说明
- atoi核心代码
- HDU 2084 数塔
- 获取状态栏高度
- spring mvc annotation总结
- windows bat
- Burp Suite Walkthrough
- Tempter of the bone
- EAS 如何设置快捷键 弹出窗口
- JMX-Notification的使用(三)
- 背包问题start...:0-1背包
- 无法在web服务器上启动调试。调试失败,因为没有启用集成windows身份验证
- HashMap和Hashtable的区别