在Web应用程序中运行小程序 [英] run applet in web application

查看:124
本文介绍了在Web应用程序中运行小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用HTML applet标记在我的web应用程序来运行简单的小程序,但它给错误,如

I want to run simple applet in my web application using html applet tag but it gives error like

抛出java.lang.ClassNotFoundException:MyApplet

java.lang.ClassNotFoundException: MyApplet

请,给我示例应用程序,如果可能的话.....

please, give me sample application if possible .....

推荐答案

问题是,小程序引擎无法找到在$ C $您MyApplet类CBase的您已经定义。

the problem is that the applet engine can't find your MyApplet class at the codebase you have defined.

因为你有你的类在你/ WEB-INF / classes目录这可以引起的。该目录由servlet引擎保护,它不是来自外部资源accesed(如可在JSP / HTML页面的小程序标记。

This can be caused because you have you class at your /WEB-INF/classes directory. This directory is protected by the servlet engine, for it not to be accesed from external resources (as can be an applet tag at a JSP/HTML page.

有解决这几个方面。最简单的一个是收拾你MyApplet类取消一个jar文件(姑且称之为 myapplet.jar ),并以入店目录保存(即您的网站的JSP文件夹应用)。
举个例子,supose您有以下文件夹为Web应用程序:

There are a few ways to solve this. The easiest one is to pack your MyApplet class un a jar file (let's call it myapplet.jar), and save it at an accesible directory (i.e. the jsp folder of your web application). As an example, supose you have the following folders for the web application:

/MyWebApp/jsp
/MyWebApp/applet
/MyWebApp/WEB-INF

客户端浏览器可以访问JSP和小应用程序文件夹中的内容。

The client browsers can access the content of jsp and applet folders.

然后,保存myapplet.jar的小应用程序文件夹,并设置你这样的小程序标记配置(suposing你的网络环境是mywebapp)时:

Then, save your myapplet.jar at the applet folder, and set your applet tag configuration like this (suposing that you web context is MyWebApp):

<applet codebase="/MyWebApp/applet" archive="myapplet.jar" 
        code="MyApplet.class" width="600" height="500">
</applet>

在这里您可以找到有关applet标记的详细信息:的http:/ /docs.oracle.com/javase/tutorial/deployment/applet/index.html

这篇关于在Web应用程序中运行小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆