在我的Spring应用程序中尝试访问MVC Controller类后,为什么我的jsp页面没有加载

时间:2018-03-14 15:43:57

标签: javascript jsp spring-mvc

我试图根据用户在另一个JSP页面(index.jsp)上提供的信息将值加载到JSP页面(xtsum)中。基本上,用户将提供一个地址,该地址将(在客户端)转换为index.jsp上的纬度和经度值。这两个double值将传递给我的控制器类(通过AJAX JQuery),因此我可以运行一个方法来查询PostgreSQL数据库,以返回原始纬度和经度1km半径范围内所有房屋的平均房价

一切正常,即纬度和经度值从客户端传递到控制器,运行方法,成功查询数据库。我有一个简单的println调试器,可以在eclipse控制台中成功打印所有内容。唯一的问题是houseprice.jsp jsp页面在其他所有正确运行后都无法加载。

Controller类中的HousePriceParser方法

houseprice

我通过导航栏中的选项卡使用AJAX JQuery在javascript端调用该函数,看起来像这样

    @RequestMapping(value = "/parseHousePrice", method={RequestMethod.POST, RequestMethod.GET})
public @ResponseBody String parseHousePrice(HousePrice housePrice, @RequestParam("latitude") double latitude,@RequestParam("longitude") double longitude, Model model) {

    // Running method that queries PostgreSQL for average price
    double housePriceAverage = parseHousePrice.ParseHousePrice(latitude, longitude);

    // Adding results from PostgreSQL db to array to get number of houses
    List<Double> housePriceList = parseHousePrice.getList();
    int housePriceListSize = housePriceList.size();

    // Simple println  debugger
    System.out.println("The average house price for this area is: " + housePriceAverage + " based on " + housePriceListSize + " property prices in this area");

    // Im trying to pass the two values calculated above to houseprice.jsp
    model.addAttribute("houseprice", housePriceAverage);
    model.addAttribute("housepricelistsize", housePriceListSize);

    // Page I'm trying to load but wont load
    return "houseprice";
}

javascript函数就是这样编写的

<li><a onclick = "parseHousePrice();" >House Price</a></li>

0 个答案:

没有答案