这些是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:Combination Sum (组合之和)

    Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C wher ...

  2. 地图之CoreLocation

    1. 在Info.plist文件中添加下面两句话 NSLocationAlwaysUsageDescription —> 确定定位吗?亲  (或者改参数类型为BOOL类型 值为Y) 请求的授权, ...

  3. css3 hover 效果

    链接 链接 链接 链接 大量级 11 22  类似拉勾  33 包括各种流行的hover 小众 极光

  4. Android UID and PID

    Android UID and PID 我们经常在一个activity中去start另一个activity,或者与另一个acitivity的结果进行交互 (startActivityForResult ...

  5. Intellij IDEA基于Springboot的远程调试

    简介 本篇博客介绍一下在Intellij IDEA下对Springboot类型的项目的远程调试功能.所谓的远程调试就是服务端程序运行在一台远程服务器上,我们可以在本地服务端的代码(前提是本地的代码必须 ...

  6. c++指针初探

    业余时间准备重温一下c++,因为在阅读Android源码到native层的时候感觉有点吃力,只是在大学时候很不用心的学过c++,所以重温下以便打好一些编程基础知识,本篇就很简单的对c++的指针做初步的 ...

  7. HAWQ取代传统数仓实践(十二)——维度表技术之分段维度

    一.分段维度简介 在客户维度中,最具有分析价值的属性就是各种分类,这些属性的变化范围比较大.对某个个体客户来说,可能的分类属性包括:性别.年龄.民族.职业.收入和状态,例如,新客户.活跃客户.不活跃客 ...

  8. RIPng 知识要点

    RIPng  --------------------------------------------------------- UDP:521 多播地址:FF02::9 -------------- ...

  9. 自己搭建MVC时遇到的一些问题及解决办法

    错误1 The view 'Index' or its master was not found or no view engine supports the searched locations. ...

  10. boost 部分编译

    完整编译boost库需要很长时间,而且我们不一定会用到所有的库. 那么如何只编译只需要的库呢? 解压boost源码,进入解压后的目录 ./bootstrap.sh生成bjam ./bjam --bui ...