简体   繁体   中英

Can I embed a Silverlight applet in my JSP (java server page)?

I suspect the answer is yes, you can embed a Silverlight applet in a JSP, but I'm having a very difficult time finding any examples of this. Seems to me that I can just use the HTML that would go in a strict HTML file...

<object width="300" height="300"
    data="data:application/x-silverlight-2," 
    type="application/x-silverlight-2" >
    <param name="source" value="SomeSilverlightApplet.xap"/>
</object>

... and it would just work.

I would test this, but finding a .xap file that I can download and test with is more difficult than I would like. Perhaps it is just because a Java programmer like myself doesn't know where to look.

Yes, you can just stick that HTML in jsp or php and it should work.

For getting it to work you will need to make sure the .xap file extension can be served up by your server. Setting that up will depend on the server platform you're running on.

BTW - here is a xap file you can test it with. Just add a twitter username in the initParams and it should run.

<param name="initParams" value="username=[YourTwitterUsername],count=10" />

您将找不到XAP,必须创建一个XAP或找到至少具有Visual Studio 2008 Standard的人员才能创建测试XAP。

That should work, or if you'd rather

<script type="text/javascript" src="Silverlight.js"></script>

(Silverlight.js outputed by a silverlight project)

and

function createSilverlight(source, parent, id)
{
   Silverlight.createObjectEx({
      source: source,
      parentElement: document.getElementById(parent),
      id: id,
      properties: {
         width: "100%",
         height: "100%",
         version: "1.1",
         enableHtmlAccess: "true" },
      events: {} });
}

where "source" is the name of a XAML file, not XAP file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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