建立一个eclipse 的 struts 2。4 的web工程
移植已经完成的工程的部分使用jsp el表达式的页面到这个新 web工程
结果发现有el的jsp 显示不正常 (《c if》等 感觉不能解释)需要如何配置在这个struts 2。4 的web新工程 里使用el表达式? (是否需要在web.xml加上代码
或者在其他地方加代码??)
移植已经完成的工程的部分使用jsp el表达式的页面到这个新 web工程
结果发现有el的jsp 显示不正常 (《c if》等 感觉不能解释)需要如何配置在这个struts 2。4 的web新工程 里使用el表达式? (是否需要在web.xml加上代码
或者在其他地方加代码??)
<!--CTYPE web-app PUBLIC </sp-->
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
在默认情况下,Servlet 2.3 / JSP 1.2是不支持EL表达式的,而Servlet 2.4 / JSP 2.0支持。
如果web.xml如下设置也不支持EL表达式:
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
解决方法:
1.修改web.xml文件为(Servlet 2.4 / JSP 2.0):
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd">
2.设置某个jsp页面使用el表达式,需要在jsp页面加上(控制单个页面)
<%@ page isELIgnored="false"%>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>
</jsp-property-group>
</jsp-config>
文章源自Web技术之家
配置如下:<%@ page isELIgnored="false"%>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp </url-pattern>
<el-ignored>false </el-ignored>
</jsp-property-group>
</jsp-config>
不能加在web。xml中 提示错误
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4"> <display-name>Myweb</display-name> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp </url-pattern>
<el-ignored>false </el-ignored>
</jsp-property-group>
</jsp-config>
</web-app>jsp如下失败
<%@ page isELIgnored="false"%>
<form id="form1" name="form1">
<%
String aa2=request.getParameter("act");
out.println("hhhhhhh"+aa2);
String aa=request.getParameter("userName");
out.println(aa); %><c:if test="${param.userName == null}">
<input id="a" type="text" name="userName" value="" />
</c:if>
<c:if test="${param.userName == '66'}">
<input id="a" type="text" name="userName" value="66" />
</c:if> <c:if test="${param.userName != '66' && param.userName != null}">
<<input id="a" type="text" name="userName" value="${param.userName}" />
</c:if>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
直接加在显示的网页上
2 在stuts配2。4
3 在jsp文件里加上一
《%%》 not <%@ page isELIgnored="false"%> 但是在web.xml 里配置是失败的俄