SpringMvc中的开启注释(整理)
来源:互联网 发布:js onclick传参 编辑:程序博客网 时间:2024/06/11 23:46
<pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- 加载包中的controller 注解扫描包 --> <context:component-scan base-package="com.xingao.controller"/> <!-- 开启注解 --><bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/><bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/><!-- 静态资源的访问 --><mvc:resources location="/img/" mapping="/img/**"/><mvc:resources location="/js/" mapping="/js/**"/><!-- 视图分解器 --><bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/"/><property name="suffix" value=".jsp"/></bean><!-- 上传文件的解析器 --><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><property name="defaultEncoding" value="utf-8"/><property name="maxUploadSize" value="10485760000"/><property name="maxInMemorySize" value="40960"/></bean></beans>
以上是来自:http://blog.csdn.net/caochuankui/article/details/17389557
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping
用处解析:
- <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" lazy-init="false"/>
- <!-- 另外最好还要加入DefaultAnnotationHandlerMapping,不然会被 XML或其它的映射覆盖!-->
- <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
所谓的注释:
<pre name="code" class="java">package com.baobaotao.web;import com.baobaotao.service.BbtForumService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.ModelAttribute;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import java.util.Collection;@Controller //<——①注释1@RequestMapping("/forum.do")public class BbtForumController { @Autowired private BbtForumService bbtForumService; @RequestMapping //<——②注释2 public String listAllBoard() { bbtForumService.getAllBoard(); System.out.println("call listAllBoard method."); return "listBoard"; }}
0 0
- SpringMvc中的开启注释(整理)
- [C++]项目中的代码注释规范(整理)
- SpringMVC(总结整理)
- android样式表类似于web开发中的CSS(亲自整理哦亲,绝对带注释)
- springmvc学习笔记(五)开启注解
- SpringMVC框架整理(一)
- SpringMVC框架整理(二)
- SpringMVC框架整理(一)
- SpringMVC框架整理(二)
- SpringMVC注释(个人学习版)
- SpringMvc整理
- C++代码注释规范(整理)
- Java注释规范整理(转)
- C++代码注释规范(整理)
- C++代码注释规范(整理)
- C++代码注释规范(整理)
- SpringMVC开启CORS支持
- SpringMVC开启CORS支持
- EEPROM分页写数据的理解
- 解决安全扫描HTTP的不安全方法
- .bat set java environment
- 一个快速打开微信收藏的方法
- [SQLServer] 50种方法优化SQL Server数据库查询
- SpringMvc中的开启注释(整理)
- 写点总结
- 漫谈程序员(八)阿里巴巴集团合伙人花名单
- iOS 解决UITabBarItem选中图片默认为蓝色的方法
- srm 556
- pure-ftpd 虚拟用户连接报错Sorry, invalid address given
- 读《50 Android Hacks》笔记整理Hack 1~Hack 8
- c++-----强制类型转换
- 当前不会命中断点 还没有为该文档加载任何符号