jsp C标签 <c:when></c:when> 使用方法***
bug 结果图:
异常显示:org.apache.jasper.JasperException: /WEB-INF/page/XX.jsp
(line: 71, column: 11) According to TLD or attribute directive in tag file, attribute test does not accept any expressions
导致界面 XX.jsp 打开页面 500
解决办法:
A 导入标签库是否合适 有两种标签库
1、将<%@taglib prefix=“c” uri=“http://java.sun.com/jstl/core”%>
更改为
<%@taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core”%>
2、JSTL标签库
将<%@taglib prefix=“c” uri=“http://java.sun.com/jstl/core”%>
更改为
<%@taglib prefix=“c” uri=“http://java.sun.com/jstl/core_rt”%>
B先验证自己的库是否合适,如果库引用正确,再检查写法是否有错
假设A是java类 a b是属性
1 <c:when test="
A
.
a
=
=
′
11111
1
′
"
>
<
/
c
:
w
h
e
n
>
2
<
c
:
w
h
e
n
t
e
s
t
=
‘
t
r
u
e
’
>
<
/
c
:
w
h
e
n
>
C
i
f
−
e
l
s
e
需
要
套
用
没
有
w
h
e
n
直
接
用
o
t
h
e
r
w
i
s
e
不
可
以
。
<
c
:
c
h
o
o
s
e
>
<
c
:
w
h
e
n
t
e
s
t
=
"
{A.a== '111111' }"></c:when> 2 <c:when test=‘true’></c:when> C if-else 需要套用 没有when直接用 otherwise不可以。 <c:choose> <c:when test="
A.a==′111111′"></c:when>2<c:whentest=‘true’></c:when>Cif−else需要套用没有when直接用otherwise不可以。<c:choose><c:whentest="{A.a== ‘111111’}">
内容A
</c:when>
<c:otherwise>
内容B
</c:otherwise>
</c:choose>
jsp:调试bug的模式:
1 如果使用<c:choose></c:choose>可以直接在jsp,debugge模式调节。
右键双击或者点击 breakponit 调节。
2 直接在jsp 页面 aaa${A.a}bbbb等标记,在空白页检查这个是否有值。