Ajax调用URL在Spring服务器上找不到@RequestMapping值


Ajax call URL cannot found @RequestMapping value on Spring server

我是使用Ajax调用和Spring服务器的初学者。我想从html发送一些JSON格式的数据到Spring服务器。这是我的Ajax调用代码:

function sendToServer(){
$.ajax({
    type: "POST",
    url:"/maricobalagi/getJsonByMap",
    dataType: "json",
    data:"{formdata}",
    //success and error message
    success: function() {
         alert("The page has been successfully loaded");
      },
     error: function() {
        alert("An error occurred");
      },
});
}

但我有一个问题与Ajax调用URL,它找不到"/getJsonByMap"值。控制台日志中有一条错误信息"POST http://localhost:8092/maricobalagi/getJsonByMap 404 (Not Found)"。下面是我的服务器代码:

public class Controller{
@RequestMapping(value = "/getJsonByMap" , method = RequestMethod.POST)
public @ResponseBody Map post(@RequestBody final Map JSONmap){
  //myCode
}
}

我只有web.xml,这是我的web.xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>Generic</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

这是我的项目文件夹:项目文件夹截图

用@RestController注释你的控制器类,并在方法中返回一些东西