基于springMVC简单开发
来源:互联网 发布:编程语言 知乎 编辑:程序博客网 时间:2024/06/09 21:32
1 导包
2 编写web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <!-- 配置Dispatcher --> <servlet> <servlet-name>springDispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 配置SpringMVC下的配置文件的位置和名称 --> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>springDispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping></web-app>
3 编写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:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 配置自动扫描的包 --> <context:component-scan base-package="com.controller"/> <!-- 配置视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"></property> <property name="suffix" value=".jsp"></property> </bean></beans>
4 编写controller
package com.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@RequestMapping("userController")@Controllerpublic class UserController { @RequestMapping("getByUserId") public String getByUserId() { System.out.println("getByUserId is executed"); return "success"; }}
阅读全文
0 0
- 基于springMVC简单开发
- 基于注解开发SpringMVC
- 简单的Springmvc基于注解
- 基于maven简单搭建SpringMVC
- 基于springmvc的简单下载
- 基于注解的SpringMVC开发
- springMVC入门---简单开发步骤
- 基于注解的SpringMVC简单介绍
- 基于注解的SpringMVC简单介绍
- 基于注解的SpringMVC简单介绍
- 基于注解的SpringMVC简单介绍
- 基于注解的SpringMVC简单介绍
- 基于注解的 SpringMVC 简单介绍
- 基于注解配置简单的SpringMVC+Mybatis
- 基于注解的 SpringMVC 简单介绍
- 基于注解的SpringMVC简单介绍
- 基于注解的SpringMVC简单介绍
- 基于注解的SpringMVC简单介绍
- 每日MySQL之007:MySQL复制之Binary Log File Position Based Replication
- QT之QStringList
- Linux改变分区表记录方式以及swap交换分区的创建
- 爬虫第一次
- 虚函数和多态
- 基于springMVC简单开发
- [主席树] Codechef: Prefix XOR
- 程序猿的一些幽默趣闻 个个经典
- Python django 入门学习系列(一)
- 利用SSH反向代理树莓派
- Vim常用快捷键
- 栈帧,反汇编解析
- H. Zé Coquinho, the sculptor 计数 括号题 2010 USP Try-outs
- (打表或数学)HDU 6063 RXD and math