How to load java applet from django template

2019-07-10 06:36发布

My applet runs file when I call it from a static applet.html file, like this:

<applet archive="applet.jar" code="com.xxx.yyy.PApplet" 
    width="100" height="20"></applet>

But how do I put the same line in a django template? And where should I put the .jar and .java files? I also noticed that it appends .class to the PApplet while looking for the file and sends me a 404 error.

I tried googling and looked into documentation, but couldn't find this issue addressed anywhere before. Thanks for your help.

2条回答
混吃等死
2楼-- · 2019-07-10 07:24

This has nothing whatsoever to do with Django.

A Java applet for client-side use needs to be served in exactly the same way as any other static assets - CSS, Javascript, etc. So you'd put it wherever those files are, configure Apache or whatever to serve from there, and reference that directory in your applet tag.

查看更多
做个烂人
3楼-- · 2019-07-10 07:33

You should use your jar file as a static media file like an image ou CSS file via MEDIA_URL.

Put applet.jar in the media directory, then use

<applet archive="{{ MEDIA_URL }}applet.jar" code="com.xxx.yyy.PApplet" 
width="100" height="20"></applet>
查看更多
登录 后发表回答