当前位置: 首页 > 知识库问答 >
问题:

如何修复Spring boot中的错误“白标错误页”

许琛
2023-03-14

我试图通过Spring Boot做API webservice,但我得到一个错误”Whitelabel错误页面此应用程序没有 /error的显式映射,所以您将此视为一个回退。

Sun Apr 21 13:42:49发生意外错误(类型=未找到,状态=404)。“没有可用的消息”

ArrestGetByConApplication.java : 

package com.arrestbycon.arrestGetByCon;
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan
public class ArrestGetByConApplication {

public static void main(String[] args) {
    SpringApplication.run(ArrestGetByConApplication.class, args);
}

}

and some of my controller :

package com.arrestbycont.arrestGetByCon;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.sql.*;
import java.util.ArrayList;
import com.arrestbycon.arrestGetByCon.Result;

@RestController
public class GetByCon {

    @RequestMapping(value = "/test", method = RequestMethod.GET)   
    public ArrayList<Result> getResult() {
      Integer arr_id;
      Integer off_id;
      String arr_code;
      String off_code;
      String off_name;

      ArrayList<Object> myArrlist = new ArrayList<Object>();

共有1个答案

何志业
2023-03-14

“白标签页面”本身并不是一个错误,而是Spring在出现错误时返回的模板,该错误没有其他自定义处理。

在提到的这个特定案例中,错误显然是您试图命中的控制器endpoint不存在(因此404代码)。只需确保使用正确的HTTP方法对正确的endpoint进行API调用。

 类似资料:
  • 我坚持使用这个简单的MVC示例。当我启动应用程序并转到localhost:8080时,我得到了“白标签错误页面”,甚至我在“src/main/资源/模板”中创建了“index.html”。我还在我的索引方法上添加了@Request estMap(“/”)。我找不到问题。 : : -在"src/main/资源/模板"下:

  • ProjectAAA.obj:错误LNK2001:未解析的外部符号" public:_ this call X::class event::class event(unsigned int)"(??0类事件@X@@QAE@I@Z) 我已经定义了不知道如何修复这个LINK错误。 欢迎提出任何建议。 谢谢你 更多信息: 1. 现在我已经完全隔离了错误: 1.

  • 问题内容: 实际上我不知道问题出在哪里。我认为这必须在创建TableLayout时进行。我不知道如何解决错误并使该应用程序正常工作。该程序显示错误“ java.lang.ArithmeticException:被零除”错误该程序具有EditText(edText),要求用户输入。它的类型是NUMBER。(这里r是edText的值)在EditText下方有一个Button(bt),它显示edText

  • 我正在做一个laravel instragram克隆网站,但突然经过一些发展当我运行php工匠服务这个错误发生。 PHP警告:require(I:\LARAVEL\LARAVEL instagram clone\vendor\composer/。/ralouphie/getallheaders/src/getallheaders.PHP):无法打开流:第66行的I:\LARAVEL\LARAVEL

  • 问题内容: 运行脚本时,出现如下错误: 警告:不能更改头信息-已经(发送了头输出在/some/file.php:12开始)在/some/file.php上线23 错误消息中提到的行包含和调用。 这可能是什么原因?以及如何解决? 问题答案: 发送头之前无输出! 在进行任何输出之前,必须调用发送/修改HTTP标头的函数。 否则,调用将失败: 警告:无法修改标头信息-标头已发送(输出从script:li