ssm项目,java返回json数据显示404,但能成功操作数据库

没有写返回的jsp页面,使用postman工具测试的

@Controller
@RequestMapping("/student")
public class StudentController {

@Resource
private StudentService studentService;

@RequestMapping("/addStudent.do")
public Map addStudent(Student student){

    Integer nums = studentService.addStudent(student);
    if(nums > 0){
        return MapUtil.echoMessage(0,"注册成功");
    }

    return MapUtil.echoMessage(-1,"注册失败");
}

}

public class MapUtil {

public static Map<String,Object> echoMessage(int code,String msg ,Object data){
    Map<String,Object> map = new HashMap<String, Object>();
    map.put("code",code);
    map.put("msg",msg);
    map.put("data",data);
    return map;
}

public static Map<String,Object> echoMessage(int code,String msg){
    Map<String,Object> map = new HashMap<String, Object>();
    map.put("code",code);
    map.put("msg",msg);
    return map;
}

}

结果:

img

@Controller 换成 @RestController
@Controller 用于返回页面,但是你没有写页面,自然就404了。
@RestController 返回json字符串。