博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springMVC简单示例
阅读量:4512 次
发布时间:2019-06-08

本文共 1205 字,大约阅读时间需要 4 分钟。

   1、新建web工程

   2、引入springframework架包

   

   

  3、配置文件

      web.xml

springmvc
org.springframework.web.servlet.DispatcherServlet
1
springmvc
/

   springmvc-servlet.xml

 

   4、源代码

package com.zay;import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;/** * Created by zadom on 2016/11/27. */@Controller@RequestMapping("/welcome")public class HelloController {    @RequestMapping(value="/hello",method = RequestMethod.GET)    public String prinWelcome(ModelMap model){        model.addAttribute("message","hello!!!");        return "hello";   //返回页面模板的名字,这个名字在mvc-dispatcher-servlet.xml中可以知道其前缀和后缀,并最终得到其jsp文件    }}

 

   5、视图文件

        hello.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>    Title${message}

 

转载于:https://www.cnblogs.com/zadomn0920/p/6111928.html

你可能感兴趣的文章
Matlab中simulink的state space模块
查看>>
IO流的标准处理代码
查看>>
UDP传输
查看>>
互联网创业公司的产品该怎么做?
查看>>
springboot+springCache+Redis声明式缓存
查看>>
[SDOI2010] 粟粟的书架
查看>>
Windows Phone 7开发资源推荐
查看>>
[LeetCode] Implement Queue using Stacks 用栈来实现队列
查看>>
[CareerCup] 6.1 Find Heavy Bottle 寻找重瓶子
查看>>
8-read及实践
查看>>
js相关笔记(十五)
查看>>
C# 将对象保存为文件 读取文件并转为对象 压缩文件 解压缩文件
查看>>
面试&笔试---c语言之字符串处理
查看>>
redis常用命令
查看>>
JSONP和HttpClient的区别
查看>>
JDK5.0新特性系列---11.1线程 Callable和Future
查看>>
【Lucene】Apache Lucene全文检索引擎架构之中文分词和高亮显示4
查看>>
「SDOI2018」物理实验
查看>>
160620、利用 jQuery UI 和 Ajax 创建可定制的 Web 界面
查看>>
基线 css
查看>>