gpt4 book ai didi

java - Java 平台企业版 (JSP) 上的 JOptionPane.showMessageDialog

转载 作者:行者123 更新时间:2023-12-01 13:37:12 25 4
gpt4 key购买 nike

我只是想知道我们可以在 Java Server Page(*.JSP) 中使用 JOptionPane.showMessageDialog 就像 ASP.NET 中的 MsgBox("Message") 吗?

我已经尝试过这段代码

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="javax.swing.JOptionPane"%>

<%
JOptionPane.showMessageDialog(null, "Message");
%>

我得到了这个:

HTTP Status 500 - Internal Server Error

最佳答案

这是不可能的,因为调用 JOptionPane.showMessageDialog 需要以下参数

public static void showMessageDialog(Component parentComponent,
Object message)
throws HeadlessException

Brings up an information-message dialog titled "Message".

Parameters:
parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
message - the Object to display

这里的父组件应该是 Component 类的有效子类,或者通俗地说是某种 swing 或 awt 框架。这是 JSP 无法提供的。

关于java - Java 平台企业版 (JSP) 上的 JOptionPane.showMessageDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21177513/

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