---
title: "Struts2使用不了EL表达式  "
author: "eoasis"
date: "2012-07-03T15:55:13Z"
tags: []
categories: ["开源软件"]
slug: "struts2-el"
draft: false
lastmod: "2012-07-03T15:55:13Z"
id: 1575811
url: "https://eoasis.iteye.com/blog/1575811"
---

Struts2默认设置El表达式禁用。我尝试修改web.xml，从整个项目的角度解除，但是依然没有效果，只能每页分别设置。

 

解决方案：

**一、在相应的页面中引用对应的taglib，并设置isELIgnored为*false***

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

 ***关键是一定要设置&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;***

 

**二、测试运行**

```
<%
    String str="123";
    request.setAttribute("str",str);
%>
    ${str }
```