Using f:view to override default contentType - cons?

可紊 提交于 2019-12-25 02:25:57

问题


I use a lot of jQuery plugins in my JSF 2.0 application and not all of them generate HTML which can successfully pass through the strict XHTML checks of webkit browsers. So the solution is to actually get into the plugin's code and correct it so that it generates a valid HTML, which is a very time consuming process in itself, or, wrap the contents of generated HTML in <f:view contentType="text/html">. The latter is quite straight forward and it works. Are there any cons of using <f:view> to override the content type in such a manner?


回答1:


JSF defaults to the closest media type in the Accept header as is been sent by the webbrowser. If the URL matches *.xhtml, then it will usually end up to be application/xhtml+xml in some browsers and text/html in other browsers. You can without any problems force it to be text/html, most browsers treat XHTML as HTML anyway. Forcing to application/xhtml+xml is however a different story: MSIE doesn't support it in any way.

See also:

  • IE's XHTML Compatibility
  • Internet Explorer wants to download the webpage of GuessNumber example application instead of displaying it
  • Is it possible to use JSF+Facelets with HTML 4/5?


来源:https://stackoverflow.com/questions/9375669/using-fview-to-override-default-contenttype-cons

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!