eclipse配置springMVC
基础还是创建一个Dynamic web project.
WEB-INF/lib中添加必需的jar。
- commons-logging-1.1.3.jar
- spring-aop-4.3.6.RELEASE.jar
- spring-beans-4.3.6.RELEASE.jar
- spring-context-4.3.6.RELEASE.jar
- spring-core-4.3.6.RELEASE.jar
- spring-expression-4.3.6.RELEASE.jar
- spring-web-4.3.6.RELEASE.jar
- spring-webmvc-4.3.6.RELEASE.jar
这些jar在spring中都有。
配置web.xml
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置Spring mvc下的配置文件的位置和名称 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
src下创建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.awu.springmvc">
</context:component-scan> <!-- 配置视图解析器 如何把handler 方法返回值解析为实际的物理视图 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name = "prefix" value="/WEB-INF/views/"></property>
<property name = "suffix" value = ".jsp"></property>
</bean>
</beans>
Tip:<context:component-scan base-package="com.awu.springmvc"> 中为相应controllers的package目录。
bean中配置的为views的解析目录。
示例代码:
package com.awu.springmvc.handlers; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class Helloworld {
@RequestMapping("/helloworld")
public String hello(){
System.out.println("hello world");
return "success";
}
}
返回字符串为“success”,那么在配置文件指定的目录下(views)创建同名jsp文件:success.jsp。
eclipse配置springMVC的更多相关文章
- Eclipse配置Struts2.x
问了我同学现在JavaWeb主流框架是哪些.他说基本框架是SSH,struts2+spring+hibernate,流行的是SSM,springmvc+spring+mybatis,原本计划学下Str ...
- Eclipse+Spring+SpringMVC+Maven+Mybatis+MySQL+Tomcat项目搭建
---恢复内容开始--- 1. 建表语句及插入数据 CREATE TABLE `book_user` ( user_id INT(11) NOT NULL AUTO_INCREMENT, user_n ...
- eclipse下SpringMVC+Maven+Mybatis+MySQL项目搭建
这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 接下来马上进入项目搭建 ...
- 手把手实战:eclipse 搭建 SpringMvc 框架环境
环境准备 eclipse jdk1.8 tomcat 7 步骤总纲 a.准备好开发环境 b.下载相关jar包 c.在eclipse 中创建好工程 d.引进下载的ja ...
- 【.net开发者自学java系列】使用Eclipse开发SpringMVC(3)
[.net开发者自学java系列]使用Eclipse开发SpringMVC(3) 标签(空格分隔): Spring RESTful 很久没继续学习java的spring了.接下来继续 回忆一下上个随笔 ...
- eclipse创建springmvc项目
一.在eclipse中创建maven-archetype-webapp项目: 1.新建项目选择maven项目 2.默认,下一步 3.选择maven-archetype-webapp,其他保持默认即可 ...
- eclipse的springMVC环境搭建并输出HelloWorld
spring简单介绍:https://www.cnblogs.com/package-java/p/10368672.html 1.创建一个Maven Project项目 点击下一步 点击下一步 2. ...
- myeclipse配置springmvc教程
之前一直是使用Eclipse创建Web项目,用IDEA和MyEclipse的创建SpringMVC项目的时候时不时会遇到一些问题,这里把这个过程记录一下,希望能帮助到那些有需要的朋友.我是用的是MyE ...
- eclipse建立springMVC 简单项目
http://jinnianshilongnian.iteye.com/blog/1594806 如何通过eclipse建立springMVC的简单项目,现在简单介绍一下. 工具/原料 eclip ...
随机推荐
- 一道无限极类 PHP 试题
记某次笔试碰到的一道无限极类试题,当时时间比较紧(满满六页试题),还是手写代码,所以最终写的有点错误.记不住原题了,但是要求都知道,特此记录下来! 试题 有下面一个数组: $arr = [ '小红' ...
- Cypress系列(53)- as() 命令详解
如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 作用 起别名以供以后使用 可在 cy.g ...
- MySQL 5.7 InnoDB锁
简介 参考https://dev.mysql.com/doc/refman/5.7/en/innodb-locking.html#innodb-gap-locks. InnoDB引擎实现了标准的行级别 ...
- [Angular JS教程] HeroService: getHeroes failed: undefined 问题解决方法
最近在学习入门Angular JS,学习资源是https://angular.cn/tutorial, 在学习到 "https://angular.cn/tutorial/toh-pt6模拟 ...
- vue中解决chrome浏览器自动播放音频 和MP3语音打包到线上
一.vue中解决chrome浏览器自动播放音频 需求 有新订单的时候,页面自动语音提示和弹出提示框: 问题 chrome浏览器在18年4月起,就在桌面浏览器全面禁止了音视频的自动播放功能.严格地来说, ...
- Java变量命名前俩个字母仅含有一个大写字母的坑
背景 前几周在做项目fetch切换,即将HttpUtils调用改成使用Feign调用.大概代码如下: // 原代码 String resultJson = HttpUtil.get(url + &qu ...
- mysql update 子查询作为条件
UPDATE t_commission_template tctJOIN ( SELECT max(id) maxid FROM t_commission_template WHERE taken_m ...
- 如何win10 上访问虚拟机(linux)上redis方法
上一回linux上安装了redis,but在window上面连接不上/??? 配置了密码,不行, 防火墙端口打开了也不行??? 1. 首先要修改redis 的配置文件,找到bind节点,修改bind的 ...
- Exists 和Not Exists使用
描述:exists表示()内子查询语句返回结果不为空说明where条件成立就会执行主sql语句,如果为空就表示where条件不成立,sql语句就不会执行.not exists和exists相反,子查询 ...
- go操作mysql数据库
Golang GORM使用 gorm gorm是go语言中实现数据库访问的ORM(对象关系映射)库.使用这个库,我们可以利用面向对象的方法,更加方便的对数据库中的数据进行CRUD(增删改查). 基本使 ...