jsp <s: if>标签问题

2025-03-11 05:18:15
推荐回答(5个)
回答1:

A:判断字符串的问题:
1、判断单个字符:
这样是从session中取出username的值,并且判断其是否为c,但是这样判断是不正确的,这样判断的话,根本判断不出来,要改成下面这样:

这样判断才能正确判断,至于原因我也不知道,在网上看到struts2中可能它判断的是char类型。
2、判断字符串:
这样写的就是判断username是不是milo,是String的判断,这个是不用加toString()的。
3、判断数值:
这样写的就是判断username是不是0,是int的判断。

B:判断为空的问题:

struts2中的判空似乎只能这么写
判断非空可以这样写:


举例:

< s:if test="#name == 'luozhh'">
Luozhh's file here
< /s:if>
< s:elseif test="#name == 'Scott'">
Scott's file here
< /s:elseif>
< s:else>
Other's file here
< /s:else>

回答2:



${titil}
${name}
${centent}

<__想在此加入标签!_>


update
delete



回答3:

改为:

回答4:

一、登陆的时候,你要把用户的ID保存在Session里。
二、在权限的地方,用该条记录所属的userid 和 session里的ID做比较。

回答5:

判断进去的这种身份的id 是否 =${id}">