从页面加载JSP删除警报 [英] Remove alert from Page Load JSP
本文介绍了从页面加载JSP删除警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Jsp页面,每次打开该页面时,都会加载警报框.我需要仅在满足某些条件时才显示此警报.这是我的JSP.每次页面加载时,这都会加载一个空警报.
I have a Jsp Page and The Alert Box is Loading every time the Page is Opened. I need this alert to display only if certain condition is met. Here Is My JSP. This is loading an empty alert every time the Page Loads.
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<LINK REL="StyleSheet" HREF="css/style.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form class ="menuOption" action ="MenuServlet" method ="GET">
<table border="0" class ="menuOption">
<tbody>
<tr>
<td>Enter Menu Option<input type="text" name="menuoption" value="" /><input type="submit" value="GO" name="gomenu" /></td>
</tr>
<tr>
<c: if test="${not empty nulloption}">
<script>alert("${nulloption}");</script>
</c:if>
<c:if test="${not empty invalidMenu}">
<script>alert("${invalidMenu}");</script>
</c:if>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
推荐答案
尝试执行此操作以验证invalidMenu
的内容.
Try this to verify invalidMenu
contents.
<tr>
<td><%= request.getAttribute("invalidMenu") %></td>
<c:if test="${not empty invalidMenu}">
<script>alert("${invalidMenu}");</script>
</c:if>
<td></td>
<% request.setAttribute("invalidMenu", "invalid menu name"); %>
<c:if test="${not empty invalidMenu}">
<script>alert("${invalidMenu}");</script>
</c:if>
<td></td>
</tr>
这篇关于从页面加载JSP删除警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文