gpt4 book ai didi

javascript - Wicket:当 Form.MultiPart(true) 时如何显示 Javascript 对话框

转载 作者:行者123 更新时间:2023-11-29 20:18:37 27 4
gpt4 key购买 nike

当我尝试在 Wicket 中上传文件时出现以下异常:

"ERROR org.apache.wicket.RequestCycle.logRuntimeException(RequestCycle.java:1529) - ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.
java.lang.IllegalStateException: ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.
at org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.<init>(MultipartServletWebRequest.java:113)..."

但是,当我设置 form.MultiPart(true) 时,我无法使用以下方法获取 Javascript 对话框:

target.appendJavascript("Some Message");

有人知道在 Form.Multipart(true) 时如何使用 Javascript 吗?

谢谢!

最佳答案

如果你想调用警告对话框作为对 ajax 请求的响应,你可以使用 appendJavascript() 方法(参数是 javascript 代码,而不是简单的字符串,就像你的代码一样发布):

target.appendJavaScript("alert('Some message');");

如果您想在页面加载时调用警报,您可以使用一种行为:

add(new AbstractBehavior() { // or Behavior, on Wicket 1.5
@Override
public void renderHead(Component component, IHeaderResponse response) {
response.renderOnLoadJavaScript("alert('Some message');");
}
});

也可以使用标签,并直接渲染到 <script> 标签。请记住调用 setEscapeModelStrings(false):

add(new Label("alert", "alert('Some message');").setEscapeModelStrings(false));

<script type="text/javascript" wicket:id="alert"></script>

关于javascript - Wicket:当 Form.MultiPart(true) 时如何显示 Javascript 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5059406/

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