0.问题描述
搭建springmvc的时候,最后一步开始渲染视图的时候发现数据渲染失败。
controller层:

jsp:

后台打印显示正常

前端页面显示不正常

可以看出,页面能请求出来,但是没有数据渲染出来。
1.解决方案
我经过了一个多小时的实验,最终发现是web.xml的问题,新建项目的时候web.xml默认是下面这样的版本
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> </web-app>
换成以下这个版本以后,重新请求就变得正常了。
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> </web-app>
现在前端就变的正常了。

返回目录:JAVA