无法返回String / Ajax输出它跳转到viewresolver“无法解析名称为xyz的视图.......”

时间:2016-11-01 11:50:54

标签: java ajax jsp servlets

  @RequestMapping(value = "/time.html", method = RequestMethod.GET)
  public @ResponseBody String getTime(@RequestParam String name) {
    String result = "Time for " + name + " is " + new Date().toString();
    return result;
  } 

//我的configuratin是:

<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver" p:basename="views" />

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" p:definitions="/WEB-INF/tiles-defs.xml" />

和jsp是

  <script type="text/javascript">
    function doAjax() {
      $.ajax({
        url: 'time.html',
        data: ({name : "me"}),
        success: function(data) {
          $('#time').html(data);
        }
      });
    }
  </script>
<button id="demo" onclick="doAjax()" title="Button">Get the time!</button>
<div id="time">

它给出了输出: javax.servlet.ServletException:在名为'dispatcher'的servlet中无法解析名称为'Time for me is Tue Nov 01 16:54:04 IST 2016'的视图

0 个答案:

没有答案