我有一个模板,其中<h:form>
被定义为。这<h:form>
在整个应用程序中用于实体的 CRUD 页面。
所以,在一个地方我需要另一个地方enctype
表格,以便我可以上传文件。我想我可以通过模板中的一个方面来解决这个问题:
<h:form id="main-form">
<f:facet name="enctype">
<ui:insert name="form-enctype"/>
</f:facet>
<ui:insert name="buttons"/><p/>
<ui:insert name="content"/><p/>
<ui:insert name="buttons"/>
<ui:insert name="additionalHelper"/>
</h:form>
在具体页面我想设置自定义enctype
这边走:
<ui:define name="form-enctype">
<h:outputText value="multipart/form-data"/>
</ui:define>
但在源代码中我总是以默认值结束application/x-www-form-urlencoded
as enctype
为了<h:form>
为什么会发生这种情况?在源代码的其他位置,此行为正常。
的参考页h:form没有提到enctype
方面。我认为这不是有效的方面h:form
。不过有属性enctype
.
如果您想在特定页面中定义表单的内容类型,请使用如下所示的模板参数。
模板将如下所示:
<h:form id="main-form" enctype="#{myenctype}">
<ui:insert name="buttons"/><p/>
<ui:insert name="content"/><p/>
<ui:insert name="buttons"/>
<ui:insert name="additionalHelper"/>
</h:form>
并且特定页面必须定义<ui:param name="myenctype" value="multipart/form-data"/>
:
<ui:composition template="template.xhtml">
<ui:param name="myenctype" value="multipart/form-data"/>
<!-- other stuff like <ui:define ...> -->
</ui:composition>
如果您想为参数提供默认值,请使用三元运算符,如中所述这个问题.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)