1. 打开Eclipse,菜单 File->New->Marven Project.

       

      2. 点击 Next,

       

       3. 选择 marven-archetype-webapp  点击 Next。

       
       4.  输入  Group Id  (可以理解为.net 里的解决方案名) , Artifact Id (可以理解为.net里的项目名),点击 Finish。新建项目成功!

5.  新建文件夹  main->java、main -> java -hello、main->resources->templates。

6. 在 main-> java 目录下加入 GreetingController.java 文件代码如下:

package hello;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class GreetingController {

@RequestMapping("/greeting")
public String greeting(@RequestParam(value="Obj", required=false, defaultValue="World") s name, Model model) {
model.addAttribute("name", name);
return "greeting";
}

}

            7.在main->resources->templates 目录下加入 greeting.html 文件作为视图模板(视图引擎用的 thymeleaf)。

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
</body>
</html>

            8.在main->main->java 目录下加入  Application.java 文件。

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

}

9. 现在项目中很多地方都会缺少引用,将鼠标移到缺少引用的语句旁,用eclipse 的 fix project 功能修复即可。

10.右键项目,菜单中选择   Run As -> Marven install.

         11.右键项目,菜单中选择   Run As -> JavaApplication.

         12.根据eclipse console 中提示的端口即可访问 hello world 页面。

Eclipse+Marven + spring mvc 新建一个 Hello world 项目的更多相关文章

  1. 通过eclipse配置Spring MVC项目

    上一篇刚建立了一个简单的Spring项目,其实Spring MVC是一个和Struts2一样的基于MVC设计模式的web框架,并且继承了MVC的优点,是基于请求驱动的轻量级的web框架,spring ...

  2. Spring MVC 处理一个请求的流程分析

    Spring MVC是Spring系列框架中使用频率最高的部分.不管是Spring Boot还是传统的Spring项目,只要是Web项目都会使用到Spring MVC部分.因此程序员一定要熟练掌握MV ...

  3. OSGI企业应用开发(十五)基于Spring、Mybatis、Spring MVC实现一个登录应用

    前面文章中,我们已经完成了OSGI应用中Spring.Mybatis.Spring MVC的整合,本篇文章我们就在这个基础上来完成一个简单的登录应用,其中用户名和密码需要从数据库中查询. 前面文章中, ...

  4. Spring MVC框架一个实例的手动实现

    文件结构: SpringMVC05 // 应用程序名 ----index.html // 欢迎文件,主目录下的文件可以被URL直接访问到 ----WEB-INF // 这个目录下的文件将被保护起来不能 ...

  5. 使用eclipse创建spring mvc web工程并部署

    创建maven工程

  6. 全网最详细的Eclipse里如何正确新建普通的Java web项目并发布到Tomcat上运行成功【博主强烈推荐】(图文详解)

    不多说,直接上干货! 首先,大家要明确,IDEA.Eclipse和MyEclipse等编辑器之间的新建和运行手法是不一样的. 如果是在Myeclipse里,则是File -> new -> ...

  7. 如何基于Spring Boot搭建一个完整的项目

    前言 使用Spring Boot做后台项目开发也快半年了,由于之前有过基于Spring开发的项目经验,相比之下觉得Spring Boot就是天堂,开箱即用来形容是绝不为过的.在没有接触Spring B ...

  8. maven新建Spring MVC + MyBatis + Oracle的Web项目中pom.xml文件

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  9. eclipse maven spring mvc el表达式无效

    http://www.myexception.cn/javascript/2031310.html

随机推荐

  1. opensns学习

    根据ThinkPHP官方文档学习opensns框架 主要看了下opensns所用的单一入口模式的意义. 基础 opensns目录结构 index.php 入口文件 Application 应用目录(含 ...

  2. termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed - 获取和设置终端属性,行控制,获取和设置波特率

    SYNOPSIS 总览 #include <termios.h> #include <unistd.h> int tcgetattr(int fd, struct termio ...

  3. svn - Subversion 命令行客户端工具

    SYNOPSIS 总览 svn command [options] [args] OVERVIEW 概述 Subversion 是一个版本控制系统,允许保存旧版本的文件和目录 (通常是源代码),保存一 ...

  4. MySQL--分组数据

    1.数据分组 #连接数据库 use newschema; #查看表中数据 select *from products: #返回供应商1003提供的产品数目 ; 2.创建分组 select vend_i ...

  5. springMVC+freemarker整合

    转自:http://angelbill3.iteye.com/blog/1980904 在springMVC的项目中,加入freemarker 1.首先导入springMVC-webmvc所需的JAR ...

  6. python_django_类视图的第一次忐忑碰触!!!

    我们Django学到这里,基础知识阶段是已经完成了!! 在我们前面接触到的视图都是基于函数的视图函数我们可以称它为FBV,而今天我们新接触的就是视图函数的另一类CBV:基于类的视图函数,我们这里拓展这 ...

  7. ssh-key添加之后依旧需要密码输入Bug的解决

    场景重现 要求从10.183.93.181的root用户ssh免密登录至10.110.155.26的boss用户 1.在10.110.155.26 的boss用户下面新建目录.ssh 2.在10.11 ...

  8. 【LeetCode 4】寻找两个有序数组的中位数

    题目链接 [题解] 假设在两个有序的序列中找第k小的数字. 那么我们先定位第一个序列中的第k/2个数字(不足则取最边上的那个数字)记下标为i1 然后定位第二个序列中的第k/2个数字(同样不足则取最边上 ...

  9. C语言新手写扫雷攻略4

    今天写的是游戏过程的函数,基本的算法前面都解释过了,今天是实现基本的功能 补充一下前面需要用到的头文件 #include<conio.h> //_kbhit() #include<s ...

  10. (转)openfire插件开发(二) 基于web的插件开发

    转:http://blog.csdn.net/lovexieyuan520/article/details/38935137 在前面的博客中,我介绍了openfire插件开发,在那篇博客中我详细的说明 ...