Scala 会话值与变量值比较时,则显示它们不相等

Scala 会话值与变量值比较时,则显示它们不相等,scala,session,playframework,Scala,Session,Playframework,我是scala和play 2.1的新手,来自php背景,在下面的代码中,会话userId和userId值相等,但其他条件正在执行,我不明白为什么会发生这种情况 @session.get("userId") //21 on webpage @println(session.get("userId")) //some(21) on console @userId //21 on webp

我是scala和play 2.1的新手,来自php背景,在下面的代码中,会话userId和userId值相等,但其他条件正在执行,我不明白为什么会发生这种情况

@session.get("userId")                  //21 on webpage
@println(session.get("userId"))         //some(21) on console
@userId                                 //21 on webpage 
@println(userId)                        //21 on console
@println(session.get("userId").get)     //21 on console
@if((session.get("userId").get)==userId){
<input type="file" value="image" style="position:absolute;opacity:0.0;" name="image" style="70px;" onchange="javascript:this.form.submit();">
}else{
<input type='button' value='Add' />
}

提前感谢

这是类型不匹配的情况。默认情况下,会话中存储的值为字符串类型。我认为userId的值是Int或long类型。因此,将会话值转换为相同的类型,即使用session.getuserId.get.toInt更改整数类型,然后进行比较。

userId和session.getuserId的类型是什么?很可能其中一个是Int,而另一个是Stringyes,我知道了。会话变量为字符串类型。scala中的问题太简单。。