1

Lift の学習を始めたのですが、行き詰まっています。シンプルなスニペットに問題があります:

class Util {

    def in(html: NodeSeq) : NodeSeq ={

        if (User.loggedIn_?)
            Helpers.bind("user", html, "name" -> User.currentUser.map(_.lastName).open_!)
        else
            NodeSeq.Empty
    }

現在のユーザー名を挿入する必要がありますが、例外が発生しています:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.scala_tools.maven.executions.MainHelper.runMain(MainHelper.java:105)
at org.scala_tools.maven.executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
Caused by: scala.tools.nsc.symtab.Types$TypeError: type mismatch;
 found   : x$1.lastName.type (with underlying type object x$1.lastName)
 required: com.liftworkshop.model.User#lastName.type
    at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:352)

何が起こっている?

4

1 に答える 1

3

ここでの問題は、_。lastNameが実際にはMappedString型のシングルトンオブジェクトであり、実際の文字列値ではないことです。文字列値を取得するには、次のことを行う必要があります。

_.lastName .is

于 2009-09-19T04:14:14.423 に答える