`
qiang106
  • 浏览: 387657 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

#{..} is not allowed in template text 问题解决

阅读更多
   刚学JSF,尝试Demo时,其中一个页面出问题了,报错:
引用
#{..} is not allowed in template text
   网上查一下,有人说是#{}EL不支持的原因,也尝试了网上提供的解决办法http://www.iteye.com/topic/286901,结果还是不行。想起之前有一个页面同样是这样写的EL,为什么没有问题呢,对比了一下发现,出错的页面的头是如下声明的:

<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">


而没有问题的页面又是如下:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>


替换成后面这种形式,问题没有再出现了,
具体原因也不去分析啦,下班了。

另外我看了一下Eclipse进行JSF开发,新建页面时提供的三种模板,另外还有一种也没有问题,如下

<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" version="2.0">
    <jsp:directive.page language="java"
        contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" />
    <jsp:text>
        <![CDATA[ <?xml version="1.0" encoding="ISO-8859-1" ?> ]]>
    </jsp:text>
    <jsp:text>
        <![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ]]>
    </jsp:text>
<html xmlns="http://www.w3.org/1999/xhtml">

……

</html>
</jsp:root>

这个形式的模板也是没有问题的,要是你也遇到这个问题了,不妨换一个模板试试!
分享到:
评论
1 楼 lvjun106 2011-09-08  
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
这种模板的写法是需要应用程序安装了facelets.
安装facelets方法需要下载jsf-facelets.jar,el-api.jar,el-ri.jar,之后在web.xml中配置facelets欲解析的文件
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
  </context-param>
及在faces-config.xml中配置faceletViewHandler
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>




相关推荐

    BURNINTEST--硬件检测工具

    Windows 98 and ME are not supported in BurnInTest version 5.3 and above. Use a version of BurnInTest prior to 5.2 for compatibility with W98 and ME. Windows 95 and Windows NT =======================...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    Now it is possible to define is the drawing take place via WMPaint or via the PaintTo direct call (if rcPaint contain non-empty rectangle then WMPaint in progress). - FIX: The TFlexPanel.FPaintCache ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    However, implementation code properly belongs in .cc files, and we do not like to have much actual code in .h files unless there is a readability or performance advantage. If an inline function ...

    数位板压力测试

    • Is the user allowed to change things that help to customize the work environment, but pre¬vented from changing things over which applications must have control? 2.2 Ease of Programming ...

    WPTools.v6.29.1.Pro

    - WPTools is configured using the file WPINC.INC, here WPREPORTER is activated and the optional WPShared, WPSPell and wPDF can be selected to be compiled into main WPTools package. - also see FAQ:...

    微软内部资料-SQL性能优化5

     If the table is a heap (in other words, it has no clustered index), the bookmark is a RID, which is an actual row locator in the form File#:Page#:Slot#. Finding Rows with a NC Index on a Heap ...

    thymeleaf-extras-springsecurity-3.0-master.zip

    Remember that Spring Security sets a special security-oriented object as expression root, which is why you would not be able to access the expectedRole variable directly in the above expression. ...

    python3.6.5参考手册 chm

    Notable changes in Python 3.6.5 What’s New In Python 3.5 Summary – Release highlights New Features PEP 492 - Coroutines with async and await syntax PEP 465 - A dedicated infix operator for matrix...

    Rad Studio Delphi C++builder XE 10.4 Patch2

    RSP-28761 [REGRESSION] E2154 Type 'T' needs finalization - not allowed in variant record RSP-28737 Compiler error when inlining new Bit Counting Standard Functions RSP-28735 Managed Records Causing ...

    acpi控制笔记本风扇转速

    exclusion and the interrupt level indication flag is not needed. Fixed a problem with the Global Lock where the lock could appear to be obtained before it is actually obtained. The global lock ...

    jQuery完全实例.rar

    This means that every time the passed-in function is executed (which is once for every element matched) the 'this' keyword points to the specific DOM element. Additionally, the function, when ...

Global site tag (gtag.js) - Google Analytics