Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 白标签错误页-Spring启动应用程序中的错误_Java_Eclipse_Spring Boot_Microservices_Spring Tool Suite - Fatal编程技术网

Java 白标签错误页-Spring启动应用程序中的错误

Java 白标签错误页-Spring启动应用程序中的错误,java,eclipse,spring-boot,microservices,spring-tool-suite,Java,Eclipse,Spring Boot,Microservices,Spring Tool Suite,运行Spring启动应用程序时,即使在映射URL之后,我也会看到白标签错误页面 我提到了application.properties文件和一个控制器文件 application.properties file server.port=8087 server.servlet.context-path=/starts spring.h2.console.enabled=true --------------------------------------------- TestControl

运行Spring启动应用程序时,即使在映射URL之后,我也会看到白标签错误页面

我提到了application.properties文件和一个控制器文件

application.properties file

server.port=8087
server.servlet.context-path=/starts

spring.h2.console.enabled=true

---------------------------------------------

TestController.java file

package com.example.firstproject.Controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.firstproject.Entity.Employee;
import com.example.firstproject.Service.EmployeeService;

@RestController

public class TestController {
@Autowired
EmployeeService empService;

    @RequestMapping("/save")
    public int test(@RequestBody Employee emp) {
        return empService.saveEmployee(emp);
        //return 0;
    }
    @RequestMapping("/getAll")
    public List<Employee> home() {
        return empService.getAll();
    }

    @RequestMapping("/test")
    public String test()
    {
        return "success";
    }
}
我还附上了在运行项目时得到的错误图像


如何删除此错误?

您的/save映射是一个POST请求,需要一个Employee对象。您不能从浏览器URL调用它。浏览器调用仅限于GET请求。您应该使用诸如Postman之类的工具发送POST请求。

您需要提及您正在执行的请求映射类型 @RequestMappingvalue=/save,method=RequestMethod.POST 或
PostMapping/save

好的,您的问题是什么?您仍然不清楚。您想避免出现错误,还是想要一个好看的错误页面?我想避免错误@stultuskey您是否在请求正文中添加了json请求对象并选择POST作为请求方法?请在控制器中为@POST或@PostMappingpath=/、consumes=application/json、products=application/json注释。我已经尝试过这样做,但仍然存在白标签错误。您是否也将内容类型头添加为application/json,您可以发布邮递员请求?是,我已经将内容类型值添加为application/json,我的邮递员请求是-