1.welcome.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Welcome</title> </head> <body> <span>hello!</span> <c:out value="${name}"></c:out> </body> </html>
2.controller
package com.cici.example.view; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/rest/v1") public class WelcomeController { @RequestMapping(value="/hello") public String index_jsp(Model model){ model.addAttribute("name", "CC"); return "welcome"; } }
原理待续...