最近创建的maven项目,向jsp中写入el表达式等内容是无法显示, 直接返回到了前端界面上.
原因
web.xml 版本过低
(我的版本是2.3)
网上查了一下,2.3里面isELIgnored
没有设置为false
一共两种解决方案
- 在jsp上添加
<%@ page isELIgnored="false" %>
,
如果页面少的话还少说, 要是多起来总不能一个一个改吧
所以就有个第二种解决办法
<%@ page isELIgnored="false" %>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
- 更换
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>
将2.3版本替换为2.3以后即可, 如图下4.0版本
<?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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
如此问题便可以完美解决!