这些是springMVC3.2所用到的jar包

web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>springmvcfirst1208</display-name> <!-- springmvc前端控制器 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- contextConfigLocation配置springmvc加载的配置文件(配置处理器映射器、适配器等等)
如果不配置contextConfigLocation,默认加载的是/WEB-INF/servlet名称-serlvet.xml(springmvc-servlet.xml)
-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
</servlet> <servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

上面我讲配置文件放在classpath下面,在项目件文件夹的时候要注意要选择新建source folder;如果新建文件夹的时候选择的是folder在调用url的时候就会提示找不到配置文件(找不到springmvc.xml)

 springmvc.xml

<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-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd "> <!-- 注解方式 适配器、解析器加载 -->
<mvc:annotation-driven></mvc:annotation-driven> <!-- 注解扫描制定的包路径 默认扫描com.mvc.controllter下的所有包含注解的类-->
<context:component-scan base-package="com.mvc.controller"></context:component-scan> <!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 配置jsp路径的前缀 -->
<property name="prefix" value="/WEB-INF/jsp/"/>
<!-- 配置jsp路径的后缀 -->
<property name="suffix" value=".jsp"/>
</bean>
</beans>

 controllter代码,没有查数据

package com.mvc.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import com.mvc.model.Items; /***商品控制器*/
@Controller
@RequestMapping("/itemsController")
public class ItemsController { @RequestMapping("/queryItems")
public ModelAndView queryItems(){ List<Items> items=new ArrayList<Items>(); Items items_1 = new Items();
items_1.setName("小米note");
items_1.setPrice(6000f);
items_1.setDetail("ThinkPad");
items_1.setCreatetime(new Date()); Items items_2 = new Items();
items_2.setName("荣耀华为plus");
items_2.setPrice(5000f);
items_2.setDetail("荣耀华为plus");
items_2.setCreatetime(new Date()); items.add(items_1);
items.add(items_2); ModelAndView modelAndView=new ModelAndView();
modelAndView.addObject("items", items);
modelAndView.setViewName("items/itemsList"); return modelAndView;
}
}

  前面springmvc.xml中将视图解析器的路径配置在/WEB-INF/jsp/下,文件名后缀为.jsp,所以对应的jsp路径就是/WEB-INF/jsp/items/itemsList.jsp

 

springMVC第一天的更多相关文章

  1. SpringMVC第一天(其他)

    SpringMVC第一天 框架课程 课程计划 参数绑定 SpringMVC默认支持的类型 简单数据类型 Pojo类型 Pojo包装类型 自定义参数绑定 SpringMVC和Struts2的区别 高级参 ...

  2. springMVC 第一章

    springMVC 第一章 一.分层结构的项目 组成方式: 表示层:页面,Servlet 业务层:业务逻辑类(service) 持久层:与数据库交互的类(dao) 程序执行的过程:表示层->se ...

  3. JAVAEE——SpringMVC第一天:介绍、入门程序、架构讲解、SpringMVC整合MyBatis、参数绑定、SpringMVC和Struts2的区别

    1. 学习计划   第一天 1.SpringMVC介绍 2.入门程序 3.SpringMVC架构讲解 a) 框架结构 b) 组件说明 4.SpringMVC整合MyBatis 5.参数绑定 a) Sp ...

  4. springMVC第一天——入门、整合与参数绑定

    大纲摘要: 1.Springmvc介绍 2.入门程序 3.Springmvc架构讲解 a) 框架结构 b) 组件说明 4.Springmvc整合mybatis 5.参数绑定 乱码问题解决 a) Spr ...

  5. springMVC第一课--配置文件

    刚学springMVC,记录下学习过程,供以后查阅(githup源码). 1,新建一个web工程.(其他按常规来) 如下:添加applicationContext.xml,webmvc-servlet ...

  6. SpringMVC第一篇【介绍、入门、工作流程、控制器】

    什么是SpringMVC? SpringMVC是Spring家族的一员,Spring是将现在开发中流行的组件进行组合而成的一个框架!它用在基于MVC的表现层开发,类似于struts2框架 为什么要使用 ...

  7. SpringMVC -- 第一个简单的程序

    学习springMVC,我们来记录下第一个HelloWord的程序 首先.我们组织须要的jar包 commons-logging-1.1.3.jar spring-aop-4.1.7.RELEASE. ...

  8. SpringMVC 课程第一天

    SpringMVC第一天   框架课程 1. 课程计划 第一天 1.SpringMVC介绍 2.入门程序 3.SpringMVC架构讲解 a) 框架结构 b) 组件说明 4.SpringMVC整合My ...

  9. 框架SpringMVC笔记系列 二 传值

    主题:SpringMVC(第一节中再回顾复习一次) 学习资料参考网址: 1.http://www.icoolxue.com 2.http://haohaoxuexi.iteye.com/blog/13 ...

随机推荐

  1. LeetCode OJ:Lowest Common Ancestor of a Binary Tree(最近公共祖先)

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  2. Python创建CRNN训练用的LMDB数据库文件

    CRNN简介 CRNN由 Baoguang Shi, Xiang Bai, Cong Yao提出,2015年7月发表论文:"An End-to-End Trainable Neural Ne ...

  3. NOIP模拟题 友好国度

    题目大意 给定一棵树,每个点有点权,求有多少组点对满足两点简单路径上的所有点点权的$gcd=1$. $n,val_i\leq 10^5$ 题解 考虑设$G_i$表示简单路径上所有点点权均为$i$的倍数 ...

  4. 高级C/C++编译技术之读书笔记(四)之定位库文件

    最近有幸阅读了<高级C/C++编译技术>深受启发,该书深入浅出地讲解了构建过程(编译.链接)中的各种细节,从多个角度展示了程序与库文件或代码的集成方法,提出了面向代码复用和系统集成的软件架 ...

  5. PS基础教程[7]如何为照片瘦身

    有没有对自己的身材有所抱怨,有没有想过让自己的照片便得苗条一些,其实只有你想不到的,没有我们做不到的,PS中可以很简单的将我们的身体进行美化瘦身,本次经验我们就来学习一下简单的操作. 方法 1.打卡P ...

  6. 【转载】Python正则表达式指南

    本文转自:http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html#!comments 1. 正则表达式基础 1.1. 简单介绍 正则表达 ...

  7. VC++ windows开机自启动设置

    设置开机启动 很多软件要求软件能够在开机时自启动,下面讲讲如何设置开机自启动. Windows设置程序的开机启动的方法有很多,这里只讲其中的一种,该方法同时适用于32位和64位的操作系统,只需将需要开 ...

  8. LINUX 11G RAC ASM磁盘组在线增加磁盘扩容

    LINUX 11G RAC ASM磁盘组在线增加磁盘扩容 1.操作系统版本 OEL 6.1 [root@cqltjcpt1 ~]# more /etc/redhat-release Red Hat E ...

  9. 获取sonar扫描结果

    api通过抓包获取 java 1.get和post方法 package com.tools.httpUtil; import java.io.BufferedReader; import java.i ...

  10. FPGA学习中的代码阅读

    不管是学FPGA还是C语言,任何一种代码的学习都离不开大量的代码阅读,也就是多看,多学习别人的代码.初学者在学习的过程中更为重要的是模仿,模仿别人的代码算法怎么去处理的,模仿多了,代码看的多了,能力自 ...