简体   繁体   English

在struts 2的对话框上显示错误消息?

[英]Showing error message on dialogue box in struts 2?

i have a login form in Struts 2 which has username and password field. 我在Struts 2中有一个登录表单,该表单具有用户名和密码字段。 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? 在struts 2中是否有任何可用的标签,或者有​​人可以将我引向类似的简短示例?

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 您可以使用此对话框或任何其他模式对话框,关于如何显示模式对话框的教程很多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM