spring mvc 注解示例
springmvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- spring mvc 注解驱动 -->
<mvc:annotation-driven />
<!-- 扫描器 -->
<context:component-scan base-package="com" /> <!-- 配置视图 解析器 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀和后缀 -->
<property name="prefix" value="/view/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
handler
package com.stone.controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; /**
* user/list.do
* user/add.do
*/
@Controller
@RequestMapping("/user")
public class UserController { @RequestMapping(value = "/list.do")
public String list() {
System.out.println("---------查询用户信息----------");
return "userinfo/user_list";
} @RequestMapping("/add.do")
public String add() {
System.out.println("---------用户信息添加------------");
return "userinfo/user_add";
} @RequestMapping("/update.do")
public String update() {
System.out.println("---------用户信息修改------------");
return "userinfo/user_update";
}
}
jsp位于WebRoot/view/userinfo/user_*.jsp;
spring mvc 注解示例的更多相关文章
- spring mvc 注解入门示例
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=" ...
- spring mvc 注解@Controller @RequestMapping @Resource的详细例子
现在主流的Web MVC框架除了Struts这个主力 外,其次就是Spring MVC了,因此这也是作为一名程序员需要掌握的主流框架,框架选择多了,应对多变的需求和业务时,可实行的方案自然就多了.不过 ...
- Spring MVC 项目示例
Spring MVC是Spring Framework的一部分,是基于Java实现MVC的轻量级Web框架.Spring的web框架围绕DispatcherServlet设计, 作用是将请求分发到不同 ...
- Spring MVC注解的一些案列
1. spring MVC-annotation(注解)的配置文件ApplicationContext.xml <?xml version="1.0" encoding=& ...
- spring mvc(注解)上传文件的简单例子
spring mvc(注解)上传文件的简单例子,这有几个需要注意的地方1.form的enctype=”multipart/form-data” 这个是上传文件必须的2.applicationConte ...
- 关于Spring mvc注解中的定时任务的配置
关于spring mvc注解定时任务配置 简单的记载:避免自己忘记,不是很确定我理解的是否正确.有错误地方望请大家指出. 1,定时方法执行配置: (1)在applicationContext.xml中 ...
- Spring MVC 入门示例讲解
在本例中,我们将使用Spring MVC框架构建一个入门级web应用程序.Spring MVC 是Spring框架最重要的的模块之一.它以强大的Spring IoC容器为基础,并充分利用容器的特性来简 ...
- spring mvc 注解 学习笔记(一)
以前接触过spring,但是没有接触spring mvc 以及注解的应用,特习之,记之: 注解了解 @Component 是通用标注, @Controller 标注web控制器, @Service 标 ...
- Spring MVC 注解[转]
[学习笔记]基于注解的spring3.0.x MVC学习笔记(九) 摘要: 本章节,仅为@SessionAttributes的功能扩展介绍介绍,结合@requestparam注解进行简易无数据库分页. ...
随机推荐
- IFields Interface 定义一个字段集合对象
Description The Fields object represents a collection of columns in a table. The term field is synon ...
- Eclipse 快捷键使用
ctrl+shift+T //查找当前工程下的某个类 实时提示 ctrl+shift+R//查找当前工程下的某个文件 实时提示 ctrl+/添加注释 Ctrl+1 快速修复(最经典的快捷键,就 ...
- angular change the url , prevent reloading
http://stackoverflow.com/questions/14974271/can-you-change-a-path-without-reloading-the-controller-i ...
- SecureCRT上传bash: rz: command not found
SecureCRT上传bash: rz: command not found -bash: rz: command not found rz命令没找到? 执行sz,同样也没找到. 安装lrzs ...
- [iOS Animation]-CALayer 定时器动画
定时器的动画 我可以指导你,但是你必须按照我说的做. -- 骇客帝国 在第10章“缓冲”中,我们研究了CAMediaTimingFunction,它是一个通过控制动画缓冲来模拟物理效果例如加速或者减速 ...
- margin负值布局(一)
搜索关键词:margin 负-100% 链接地址: 负margin用法权威指南 负边距(negative margin)实现自适应的div左右排版 <div class="cont& ...
- BCB实现BMP图片的RGB分解(转)
源:BCB实现BMP图片的RGB分解 1.打开BMP图片文件,在Image控件中显示: if(dlgOpen1->Execute()) { edt1->Text=dlgOpen1-> ...
- LPC1788 nand驱动
Lpc 1788自带有emc接口用于驱动nandflash,norflash,sdram设备,对于nandflash驱动因为配置简单,时序也简单 首先,针对nandflash而言应当在系统中有三个地址 ...
- iOS通过代码关闭程序
//-------------------------------- 退出程序 -----------------------------------------// - (void)exitAppl ...
- 485. 找出二进制串中连续的1的个数 Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1, ...