繁体   English   中英

JFileChooser无法在tomcat服务器上打开,但在使用Eclipse运行时会打开

[英]JFileChooser not opening on tomcat server but it opens when it runs using eclipse

我已经使用struts 2创建了一个Web应用程序,我想要一个文件夹选择器,该选择器在单击浏览按钮后将被激活。 我创建了一个使用JFileChooser生成窗口的类。

public class Folderpath extends JPanel{
private String pathd;
      public String Folderpath() {

          JFileChooser chooser = new JFileChooser();
            chooser.setCurrentDirectory(new java.io.File("."));
            chooser.setDialogTitle("Choose Directory");
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setAcceptAllFileFilterUsed(false);

            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)    {
                setPathd((chooser.getCurrentDirectory()).toString());
                return "success";
              } 
            return "success";
        }
    public String getPathd() {
        return pathd;
    }
    public void setPathd(String pathd) {
        this.pathd = pathd;
    }   
}

每当我在eclipse服务器上运行项目时,它就可以工作,但是只要在tomcat服务器上尝试该项目,文件夹选择器窗口就不会开放。 我以为tomcat不允许运行applet,请指导我在tomcat服务器上运行此代码。

如果要在基于Tomcat服务器的Web应用程序上运行此代码,则必须使用applet。 在这种情况下,应使用自签名小程序。 从另一个SO线程检查此链接

暂无
暂无

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

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