<%Object userType=session.getAttribute("UserType");
if(userType != null)
{
String usert = (String)userType;out.println("public".equals(usert));
}
%>
if(userType != null)
{
String usert = (String)userType;out.println("public".equals(usert));
}
%>
if(userType != null)
{
String usert = (String)userType;out.println("public".equals(usert));
}
%>正解
还是错误得,
我不知道是不是我得session定义得有问题!
我是用JSTL来定义我得seesion得
----------------------------------------
<sql:query var="UserLog" dataSource="${Communicate}">
SELECT UserName,UserType,count(*) as islog
FROM TUser
where UserName='${param.UserName}' and Password='${param.Password}' and UserType='${param.UserType}'
Group by UserName,UserType
</sql:query>
<c:forEach var="row" items="${UserLog.rows}">
<c:choose>
<c:when test="${row.islog!=0 and param.UserType eq 'public'}">
<c:set value="${row.UserName}" var="UserName" scope="session"/>
<c:set value="${row.UserType}" var="UserType" cope="session"/>
<c:redirect url="test.jsp"/>
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
</c:forEach>
----------------test.jsp---------------------<%Object userType=session.getAttribute("UserType");
if(userType != null)
{
String usert = (String)userType;out.println("public".equals(usert));
out.println("public");
out.println(usert);
}
%>
------------------------------------------------------------------
两个打印出来都是public但是比较得救国结果还是false,不知道为什么!
郁闷死了,昨天搞了一天!
请各位大虾们帮忙,分数不够,再给!
一语惊醒梦中人哪,
问题解决,马上送分!
也谢谢各位捧场!