---
title: "#{..} is not allowed in template text"
author: "hua04104"
date: "2013-02-27T10:33:24Z"
tags: []
categories: ["Web前端"]
slug: "is-not-allowed-in-template-text"
draft: false
lastmod: "2013-02-27T10:33:24Z"
id: 1815759
url: "https://hua04104.iteye.com/blog/1815759"
---

最近在处理jsp页面时提示错误“tomcat #{..} is not allowed in template text”；同样的jsp运行成tomcat5.0及5.5上都没有问题，一旦在tomcat6.0上运行就会出现如上问题，经过一番网络搜索，发现原来是JSP2.1规范对#{…}的兼容性问题，原来tomcat5.0及5.5用的是JSP2.0规范，而tomcat6.0则是2.1的规范。 解决方案： step1.在页面定义字符串变量； step2.把需要#的位置用刚才定义的变量替换； &lt;% String a = " # " ; %&gt;