lift中的snippet中报错not found

本文探讨了因方法签名不正确导致的MethodNotFound错误,并提供了如何修正的示例代码。文中还讨论了代码片段中特殊字符的使用及它们对程序运行的影响。
报错代码信息:
Snippit with incorrect signature gets invoked, but erroneously produces "Method Not Found"


将 "howdy" 方法改为以下内容:

def howdy = {
System.out.println("FOO")
0
}; // <span>Welcome to hyperview at {new root.java.util.Date()}</span>


打开 http://localhost:8080/,控制台报错输出:

>FOO
>WARN - Snippet Failure: SnippetFailure(/ -> ParsePath(List(index),,true,false),Full(helloWorld.howdy),Method Not Found)
[quote]
either the method should not be invoked because the signature is wrong (therefore not emitting "FOO"), or the error message to be changed to say that the method was found, but the signature is incorrect.[/quote]
以上引用是外文网站上的说明,说的应该是方法签名出错,不应该存在大括弧。

而且下面两段代码第一段运行会报错,第二段是正确的:
def hello =<div>hello world</div>

def hello = <div>hello world</div>


第二段的"="与<div>之间有个空格,如果没有这个空格就会报错。

另外,以下代码作为代码片断嵌入页面时:
def render = {new java.util.Date}//不会有输出

def render = <span>{new java.util.Date}</span>//输出当前时间


最终的代码:
package x.y.snippet

import java.util.Date

class Util {
def in = <span>xxxxxxxxxxx yyyyyyyyyyyyyyyyyyyy</span>
def out = <span>xxxxxxxxxxxxxx</span>
def demo = <span>demo demo demo</span>
def hello = <div>hello world</div>
def render = <span>{new java.util.Date}</span>
}


调用代码:
<lift:Util.in />
<lift:Util.out />
<lift:Util.demo />
<lift:util.hello />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值