简体   繁体   English

如何在Google AppEngine中将HTML转换为内联CSS?

[英]How do I convert HTML to inline CSS in Google AppEngine?

I saw this question and I was able to convert HTML with a separate stylesheet to one with inline CSS. 我看到了这个问题 ,我能够将带有单独样式表的HTML转换为带有内联CSS的样式表。 However, when I tried to run it in Google AppEngine, it complained 但是,当我试图在Google AppEngine中运行它时,它抱怨道

java.lang.NoClassDefFoundError: java.io.FileOutputStream is a restricted class. java.lang.NoClassDefFoundError:java.io.FileOutputStream是一个受限制的类。 Please see the Google App Engine developer's guide for more details. 有关详细信息,请参阅Google App Engine开发人员指南。

I worked around that problem then it complained again 我解决了这个问题,然后又抱怨了

Caused by: java.lang.NoClassDefFoundError: java.awt.Color is a restricted class. 引起:java.lang.NoClassDefFoundError:java.awt.Color是一个受限制的类。 Please see the Google App Engine developer's guide for more details. 有关详细信息,请参阅Google App Engine开发人员指南。

So I don't think I can use that CSSBox library. 所以我认为我不能使用那个CSSBox库。 Is there another way to convert HTML to inline CSS HTML in Google AppEngine? 还有另一种方法可以将HTML转换为Google AppEngine中的内联CSS HTML吗?

The JRE Class White List provides a list of classes that can be used from the JRE. JRE类白名单提供了可以从JRE使用的类列表。

The above 2 classes that it is complaining about are not in that list and you cannot use them. 它抱怨的上述2个类不在该列表中,您无法使用它们。 You will either have to look for alternatives (other libraries), see if those classes can be dropped from the JAR (without ofcourse affecting your functionality) and so on. 您将要么寻找备选方案(其他库),看看是否可以从JAR中删除这些类(不影响您的功能)等等。

Maybe you could use a historical version of CSSBox that is based on CSSParser instead of the newer jStyleParser . 也许您可以使用基于CSSParser而不是较新的jStyleParser的CSSBox的历史版本。 It is probably less efficient (all data is represented as strings) but it has less dependencies. 它的效率可能较低(所有数据都表示为字符串)但依赖性较低。

The way of use remains more or less the same, see the ComputeStyles demo for that version. 使用方式或多或少保持不变,请参阅该版本的ComputeStyles演示 It should depend only on clases from org.fit.cssbox.css -- these should be acceptable for GAE. 它应该仅依赖于来自org.fit.cssbox.css的 clases - 这些应该是GAE可接受的。 However, I have no experience with using the CSSParser on GAE. 但是,我没有在GAE上使用CSSParser的经验。

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

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