设为首页 加入收藏

TOP

IDEA+Maven平台,Springboot渲染freemarker失败的原因和解决方法(Whitelabel Error Page type=Not Found, status=404)(一)
2019-09-17 18:44:35 】 浏览:46
Tags:IDEA Maven 平台 Springboot 渲染 freemarker 失败 原因 解决 方法 Whitelabel Error Page type Not Found status 404

利用idea和maven作为开发环境,通过springboot+mysql+Jpa完成主要后端开发后,现在往工程里引入Redis数据库缓存和前端freemarker时,发现工程不识别前端freemark的ftl文件。

经过半夜的奋战把问题解决了。现在把错误消息,发生问题时的情景,重试的手段以及最终问题解决的方法在这里分享一下。

 

画面显示的异常信息:
*************************************
Whitelabel Error Page

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

Thu Oct 26 13:42:36 GMT+08:00 2017
There was an unexpected error (type=Not Found, status=404).
No message available
**************************************

controller:
==================
package com.michael.fm1.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@Controller
public class hello {

@RequestMapping(value = "/hello", method = RequestMethod.GET)
public ModelAndView hello(Map<String,Object> map){
map.put("key","value");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("web");
modelAndView.addObject(map);
return modelAndView;
}
}
===================

springbootApplication:
===================
package com.michael.fm1;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Fm1Application {

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

application.properties
===================
空文件
===================

pom.xml
===================
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

<!--<dependency>-->
<!--<groupId>org.freemarker</groupId>-->
<!--<artifactId>freemarker</artifactId>-->
<!--</dependency>-->

</dependencies>
===================

resources/templates下的web.ftl
===================
<h1>this is a tittle</h1>
===================

问题解决的过程:
基于上面的错误信息,经历了各种尝试:
尝试1 新建项目,只留上面最小量的代码。浏览器访问controller,渲染ftl。验证失败。
尝试2 尝试引入thymeLeaf,舍弃fr

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇ELK系列~nxlog实现多位置文件的收.. 下一篇简易RPC框架-上下文

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目