当我运行应用程序时,生成的 HTML如下所示:
<HTML><head><Meta @R_419_6822@-equiv="Content-Type" content="text/HTML; charset=utf-8"><Meta @R_419_6822@-equiv="X-UA-Compatible" content="IE=10;Chrome=1"><style type="text/CSS">HTML,body {height:100%;margin:0;}</style><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./VAADIN/themes/custombootstrap/favicon.ico"><link rel="icon" type="image/vnd.microsoft.icon" href="./VAADIN/themes/custombootstrap/favicon.ico"><link rel="stylesheet" type="text/CSS" href="./VAADIN/themes/custombootstrap/styles.CSS"><script type="text/JavaScript"...
我想更改“元”属性,添加“链接”并添加一些其他组件,如:
<!--[if lt IE 9]> <script src="@R_419_6822@s://oss.maxcdn.com/libs/HTML5shiv/3.7.0/HTML5shiv.Js"></script> <script src="@R_419_6822@s://oss.maxcdn.com/libs/respond.Js/1.4.2/respond.min.Js"></script><![endif]-->
Vaadin有办法做到这一点吗?
谢谢!
public class bootstrapServlet extends VaadinServlet {private static final long serialVersionUID = 1L;@OverrIDeprotected voID servletinitialized() throws servletexception { super.servletinitialized(); getService().addSessionInitListener(new SessionInitListener() { private static final long serialVersionUID = 1L; @OverrIDe public voID sessionInit(SessionInitEvent event) { event.getSession().addbootstrapListener( new bootstrapListener() { private static final long serialVersionUID = 1L; @OverrIDe public voID modifybootstrapFragment( bootstrapFragmentResponse response) { } @OverrIDe public voID modifybootstrapPage(bootstrapPageResponse response) { if(response.getRequest().getheader("User-Agent").contains("MSIE 8.0")){ response.getdocument().head().appendElement("script").attr("type","text/JavaScript").attr("src","@R_419_6822@s://oss.maxcdn.com/libs/HTML5shiv/3.7.0/HTML5shiv.Js"); response.getdocument().head().appendElement("script").attr("type","@R_419_6822@s://oss.maxcdn.com/libs/respond.Js/1.4.2/respond.min.Js"); } }} ); } }); }}
然后从中更改web.xml中的默认servlet
<servlet><servlet-name>myappname</servlet-name><servlet-class>com.vaadin.server.VaadinServlet</servlet-class>...
至
<servlet><servlet-name>myappnam</servlet-name><servlet-class>your.package.name.bootstrapServlet</servlet-class>...
这不会添加
<!--[if lt IE 9]>
但是它会根据UserAgent是否为IE 8有条件地添加脚本.
仅供参考,我实际上是在尝试做同样的事情,因为我在我的项目中使用了twitters bootstrap,媒体查询.这些脚本是否与Vaadin 7一起工作还有待观察.
总结以上是内存溢出为你收集整理的如何在Vaadin中更改默认HTML模板全部内容,希望文章能够帮你解决如何在Vaadin中更改默认HTML模板所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)