程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了为什么我会收到 Error WhiteLabel 错误页面大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决为什么我会收到 Error WhiteLabel 错误页面?

开发过程中遇到为什么我会收到 Error WhiteLabel 错误页面的问题如何解决?下面主要结合日常开发的经验,给出你关于为什么我会收到 Error WhiteLabel 错误页面的解决方法建议,希望对你解决为什么我会收到 Error WhiteLabel 错误页面有所启发或帮助;

我写了一个简单的网络应用

DemoApplication.kt

package com.example.demo

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class DemoApplication

fun main(args: Array<String>) {
    runApplication<DemoApplication>(*args)
}

student.kt 是一个模型

package model

data class student(
    val ID: Int,val facultyID: Int,val name: String,val coursenumber: Int,)

studentDao.kt 是一个 Dao 类

package example

import model.student
import org.springframework.stereotype.Component


class studentDao: AbstractstudentDao {
    val data = listof(
        student(1,2,"Peter Ivanov",3),student(2,1,"Ivan Petrov",1),student(3,"Vasiliy Smirnov",4),student(4,"Vitaliy Kozlov",2),)

    overrIDe fun getstudent(ID: int): student {
        return data.filter{it.ID == ID}[0]
    }
    overrIDe fun getstudent(): List<student>{
        return data
    }
}

我的模型的studentComponent.kt组件

package example

import org.springframework.stereotype.Component
import org.springframework.stereotype.service

@service
class studentComponent(private val dao: AbstractstudentDao) {
    fun getExamplestudent(ID: int) = dao.getstudent(ID)
    fun getExamplestudent() = dao.getstudent()
}

AbstractstudentDao.kt 组件摘要

package example

import model.student
import org.springframework.stereotype.Component
import org.springframework.stereotype.Repository

@Repository
interface AbstractstudentDao {
    fun getstudent(ID: int): student
    fun getstudent(): List<student>

}

studentController.kt 最后是控制器

package API

import example.studentComponent
import model.student

import org.springframework.web.bind.Annotation.GetMapPing

import org.springframework.web.bind.Annotation.requestMapPing
import org.springframework.web.bind.Annotation.RestController
@RestController
@requestMapPing("/st")
class studentController(val studentComponent: studentComponent) {

    @GetMapPing
    fun getstudent(): List<student> {
        return studentComponent.getExamplestudent()
    }


}

请求是在 Controller 中基于 studentComponent 创建的。我试图得到正确的答案,但最终却得到了白标错误。我意识到错误本身是由于缺少错误处理,但有一个事实是错误与实现有关。你能帮我吗?

application.propertIEs server.port=8080

因此,http://localhost:8080/st URL 上存在错误

解决方法

欢迎来到 SO。执行此操作时,您似乎已将所有上下文路径映射到 /st

@requestMapping("/st")

不太确定您是否收到 http://localhost:8080 的白标错误。如果是这种情况,请尝试点击 http://localhost:8080/st

这应该可以解决问题。如果没有,请将 URL 放在问题中 - 您尝试访问并遇到问题的 URL。

大佬总结

以上是大佬教程为你收集整理的为什么我会收到 Error WhiteLabel 错误页面全部内容,希望文章能够帮你解决为什么我会收到 Error WhiteLabel 错误页面所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。