Spring Boot 无法呈现(非常)简单的 index.jsp

我正在尝试渲染一个 html .jsp,其中只有一个 h1 标签......感觉它应该可以工作,但它没有。


如何让 index.jsp 文件呈现到我的浏览器中?请帮忙!


我正在使用:Maven 3.5.4 Java 1.8.0_181 STS 版本:3.9.5.RELEASE


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

    <h1> hello</h1>

</body>

</html>

我成功登录到被命中的路由,但没有读取 index.jsp。


package com.coding.test1;


import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;


@SpringBootApplication

@Controller

public class Test1Application {


    public static void main(String[] args) {

        SpringApplication.run(Test1Application.class, args);

    }

    @RequestMapping("/")

    public String index() {

        System.out.println("+++++hit main+++++++");

        return "index.jsp";

    }

}

日志


+++++命中主要++++++++


浏览器显示


Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.


Mon Sep 10 20:49:47 PDT 2018

There was an unexpected error (type=Not Found, status=404).

No message available

应用程序属性


spring.mvc.view.prefix=/WEB-INF/

块引用


心有法竹
浏览 305回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java