问题描述
我在 Struts 2 中有一个登录表单,其中包含用户名和密码字段.我想要的是当用户提交表单并且如果它不是有效用户时,我想在对话框中显示错误消息(而不是在登录表单本身中显示错误消息).struts 2 中是否有任何可用的标签,或者有人可以指出类似的简短示例?
i have a login form in Struts 2 which has username and password field. what i want is when user submit the form and if it is not a valid user, i want to show the error message in a dialogue box (instead of showing the error message in login form itself). Is there any tag available in struts 2 for this or somebody can point me to similar kind of brief example?
推荐答案
把这个放在你的登录页面(你回到这里是正确的,登录无效?)
put this in your login page(you are returning here right, on invalid login?)
<script>
<s:if test="hasActionErrors()">
showDialog("<s:actionerror/>");
</s:if>
function showDialog(msg){
//your logic to show dialog goes here
}
</script>
这是一篇博文,解释了如何设计类似于堆栈溢出的通知.您可以使用这个或任何其他模态对话框,有很多关于如何显示模态对话框的教程
Here is a post which explains how to design a notification similar to stack overflow. You can use this or any other modal dialog, there are many tutorials on how to show a modal dialog
这篇关于在 struts 2 的对话框上显示错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!