Play 2.0 Framework external Model in Template

前端 未结 1 543
天涯浪人
天涯浪人 2020-12-21 06:10

Is it possible in Play 2.0, to make use of external model objects in a template?

I can reference model objects from another jar in a Controller class. I don\'t know

相关标签:
1条回答
  • 2020-12-21 06:33

    No problem. First, add the class to your classpath, either by adding the jar to the lib dir or through the "managed dependencies" in the projects/Build.scala. Make sure to have fully qualified name when declaring your model class in the template view file. Inside the template, you can reference any public method or member.

    @(varName : fully.qualified.name.MyClass)
    <h1>@varName.myMember</h1>
    <h1>@varName.myMethod</h1>
    
    0 讨论(0)
提交回复
热议问题