spring 入门案列
来源:互联网 发布:php server 编辑:程序博客网 时间:2024/06/10 07:36
http://download.csdn.net/download/qq_34125999/9970998 所需要的 包
1 案列视图
2 配置 web.xml
<!-- 配置 Spring MVC 的前端控制器,DispatcherServlet 用来拦截用户的请求 -->
<servlet>
<!-- Servlet 的名字 -->
<servlet-name>springmvc</servlet-name>
<!-- 对应的类 -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置参数 -->
<init-param>
<!-- 参数名 -->
<param-name>contextConfigLocation</param-name>
<!-- 参数路径 -->
<param-value>classpath:spring/spring-config.xml</param-value>
</init-param>
<!-- 启动时立即加载 -->
<load-on-startup>1</load-on-startup>
</servlet>
<!-- 映射声明 -->
<servlet-mapping>
<!-- 请求对应的名称 -->
<servlet-name>springmvc</servlet-name>
<!-- 监听所有的请求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
3 配置 spring-config
<?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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd ">
<!--自动扫面 com.demo.controller 下的类,看是否有相关的注解类 -->
<context:component-scan base-package="com.demo.controller"/>
<!-- 配置视图解析器-->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
4 写测试 controller
package com.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class test {
@RequestMapping(value="/hello")
public String hello(){
System.out.println("hello");
return "index";
}
}
5 运行
阅读全文
0 0
- spring 入门案列
- Mybatis入门案列
- dubbo,zookeeper,spring 案列
- struts2官方入门案列curd 编辑
- Selenium3 自动化测试入门案列
- spring mvc 学习案列介绍
- Spring MVC注解的一些案列
- spring MVC 登录拦截案列
- 简单的JMS入门案列(一)
- (1)51单片机入门案列-LED模拟交通灯
- Spring 入门
- Spring 入门
- Spring 入门
- Spring入门
- Spring入门
- Spring入门
- Spring入门
- Spring 入门
- 京东2018秋招编程题
- 009、Java中的参数传递问题
- 递归的全排列产生算法
- 机器学习随笔之KNN分类
- 前端之HTTP(二)
- spring 入门案列
- HTML打开Windows文件管理系统
- lvds原理
- 雾计算 云计算 边缘计算
- 欢聚时代2017前端笔试C卷
- Servlet 访问路径的三种配置方式
- 数据库(第一范式,第二范式,第三范式)
- debug日志
- mysql索引的区别