zoukankan      html  css  js  c++  java
  • java web mvc中,访问jsp页面

    controller:

        @RequestMapping(value = "/pass/pointInfo.do", method = RequestMethod.GET)
        public String pointInfo(HttpServletRequest request) {
            return "pointinfo";
        }

    这边的用的GET方式,返回的string类型,这样可以在浏览器中直接访问。

    pointinfo是jsp文件,放在WEB-INF文件夹下。

    接下来是jsp文件中,获取后端传递的值:

    改一下controlller, 添加一个Model类型的参数, Model是org.springframework.ui类型。

    :

        @RequestMapping(value = "/pass/pointInfo.do", method = RequestMethod.GET)
        public String pointInfo(HttpServletRequest request, Model model) {
            Map<String, Object> params = getParams(request);
            //System.out.println(JSON.toJSONString(params));
            Map<String, Object> info = locationByEsService.pointInfo(params);
            model.addAttribute("info", info);
            return "pointinfo";
        }

    其中info是查询出来的数据。

    jsp中获取参数的写法如下:

    <script type="text/javascript">
        var info = "${info}";
        var infoObj = JSON.parse(info);
    </script>
  • 相关阅读:
    [NOIP2013] 提高组 洛谷P1979 华容道
    Vijos P1404 遭遇战
    CodeVS 1506 传话
    P1546 最短网络 Agri-Net
    HDU 4747 Mex
    POJ1020 Anniversary Cake
    【数据结构】平衡二叉树
    【数据结构】二叉排序树
    【数据结构】二叉树
    概念源于生活
  • 原文地址:https://www.cnblogs.com/chenmz1995/p/12294086.html
Copyright © 2011-2022 走看看