网页中点击button按钮获取数据库中的内容。前提:数据库、 springboot框
架。整体项目布局如下图所示:
其中java中HelloController 代码如下
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@Controller
@RestController
@RequestMapping("/ajax")
public class HelloController {
@Autowired
private JdbcTemplate jdbcTemplate;
@ResponseBody
@RequestMapping("/map")
public Map<String, Object> map() {
List<Map<String, Object>> m