1. 程式人生 > >Build Spring MVC development environment

Build Spring MVC development environment

spring mvc

Short memo for how to build Spring MVC develepmnet environment (for windows). In case you have any questions, please feel free to leave message to me under this article. I will update and add more details according to your concern.


Firstly, please make sure you have eclispe and tcomcat installed locally and intergrated as expected.


1.Spring framwork download

http://repo.spring.io/release/org/springframework/spring/

技術分享圖片


2. Apachce Commons Logging Download

https://commons.apache.org/proper/commons-logging/

技術分享圖片

(Download commons-logging-1.2-bin.zip, you can also find it in attached file)

技術分享圖片

3.two more jstl jar (Please refer to attached files.)

技術分享圖片


Now Config and Test.


New Dynamic Web Project on Eclipse (Project Name: spring-mvc-demo)

技術分享圖片

Copy all the jar files to /WEB-INF/lib

技術分享圖片

Config xml files under WEB-INF. (Please find them in attached file)

技術分享圖片

Create Congtroller class. (HomeController.java)

Define Controller method.

Add Request Mapping to Controller method

Return View Name

package com.marvin.springdemo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
  @RequestMapping("/")
  public String showPage() {
   // return to main-menu page
   return "main-menu";
  }
}

Develop View Page (main-menu.jsp)

<!DOCTYPE html>
<html>

<body>
<h2>Spring MVC Demo - Home Page</h2>
</body>
</html>

File hierachy.

技術分享圖片

Run on Server

技術分享圖片





本文出自 “Marvin” 博客,請務必保留此出處http://marvinchen.blog.51cto.com/6457668/1983354

Build Spring MVC development environment