gpt4 book ai didi

zk - 如何获取 zk zhtml url 参数?

转载 作者:行者123 更新时间:2023-12-03 22:33:20 28 4
gpt4 key购买 nike

我正在使用 Zk 框架并尝试从 zhtml 页面获取 url 参数。我试过:

Executions.getCurrent().getParameter("param");

尽管我在客户端尝试了 zscript 并在服务器端尝试了页面编辑器,但它不适用于 zhtml。但它适用于 zul 页面。我如何获取 zhtml 的 url 参数作为示例:

http://localhost:8080/pystest/reset_password.zhtml?param=xxx

这是我的 zhtml 页面:

<!DOCTYPE html>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?>
<html lang="en" xmlns:zk="zk" xmlns:z="zul">
<head>
<meta charset="UTF-8"/>
<title>Reset Password</title>

<meta name="description" content="User reset password page" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- basic styles -->

<link href="css/strap.css" rel="stylesheet" />
<link rel="stylesheet" href="css/font.css" />

<!-- fonts -->

<link rel="stylesheet" href="css/ace-fonts.css" />

<!--styles -->

<link rel="stylesheet" href="css/min.css" />
<link rel="stylesheet" href="css/tlr.css" />
</head>
<body class="pass-layout">
<z:div sclass="main-container" apply="component.ResetPasswordComposer">
<div class="main-content">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="pass-container">
<div class="position-relative">
<div id="resetpass-box" class="resetpass-box visible widget-box no-border">
<div class="widget-body">
<div class="widget-main">
<h4 class="header green lighter bigger">
<i class="icon-group blue"></i>
Choose your new password.
</h4>

<form>
<fieldset>
<label class="block clearfix">
<span class="block input-icon input-icon-right">
<z:textbox type="password" class="form-control" placeholder="New password" id="password1" />
<i class="icon-lock"></i>
</span>
</label>

<label class="block clearfix">
<span class="block input-icon input-icon-right">
<z:textbox type="password" class="form-control" placeholder="Verify password" id="password2"/>
<i class="icon-retweet"></i>
</span>
</label>

<div class="space-24"></div>

<div class="clearfix">
<button type="reset" class="width-30 pull-left btn btn-sm">
<i class="icon-refresh"></i>
Reset
</button>

<button id="resetButton" type="button" class="width-65 pull-right btn btn-sm btn-success">
Submit
<i class="icon-arrow-right icon-on-right"></i>
</button>
</div>
</fieldset>
</form>
</div>

<div class="toolbar center">
</div>
</div><!-- /widget-body -->
</div><!-- /resetpass-box -->
</div><!-- /position-relative -->
</div><!-- /pass-container -->
</div><!-- /col-sm-10 col-sm-offset-1 -->
</div><!-- /row -->
</div><!-- /main-content -->
</z:div><!-- /main-container -->

<!-- below script is not working -->
<zk:zscript>
<![CDATA[
alert(Executions.getCurrent().getParameter("param"));
]]>
</zk:zscript>
</body>
</html>

和服务器端:

public class ResetPasswordComposer extends GenericForwardComposer<Component> {

/**
*
*/
private static final long serialVersionUID = 1L;

protected Textbox password1;
protected Textbox password2;

@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
}

public void onClick$resetButton(){
UserOperator userOperator=new UserOperator();
try{
String token=getToken();
System.out.println(token);
}catch(Exception e){
e.printStackTrace();
}

}

private String getToken(){
Execution exec = Executions.getCurrent();
String param=exec.getParameter("param");
return param;
}
}

最佳答案

你的问题其实是

private String getToken(){
Execution exec = Executions.getCurrent();
String param=exec.getParameter("param");
return param;
}

仅在 doAfterCompose cyclus 中可用。

在那里询问并将其保存为全局字符串。

关于zk - 如何获取 zk zhtml url 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20813446/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com