SpringMvc基础练习

1.框架
java web 开发中的 概念


SpringMvc基础练习_第1张图片
Java模拟图
  1. 基础程序
SpringMvc基础练习_第2张图片
基础项目构成
SpringMvc基础练习_第3张图片
输出结果

Controller--类:
package cn.nokia.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HellowController {

@RequestMapping("index")
public @ResponseBody List doindex() {
// TODO Auto-generated method stub
List > list = new ArrayList<>();
Map map = new HashMap<>();

  map.put("age", "24"); 
  map.put("name", "邹伟");
  list.add(map);  
  return list;

}}

Mapper-接口:

package cn.nokia.mapper;

import java.util.List;
import java.util.Map;

public interface kpimapper {
List>selectall();
List>selectkpi();
}

Service--接口:

package cn.nokia.service;

import java.util.List;

public interface HellowService {
public List doHello();
}

Service impl-类:

package cn.nokia.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import cn.nokia.service.HellowService;
@Service("helloservice")
public class HellowServiceImpl implements HellowService{
@Override
public List doHello(){
List> list = new ArrayList<>();
Map map = new HashMap<>();
map.put("name", "zouwei");
map.put("age", "24");
list.add(map);
return list;
}
}

你可能感兴趣的:(SpringMvc基础练习)