---
title: "Element type &quot;len&quot; must be followed by either attribute specifications, &quot;&gt;&quot; or "
author: "bd2007"
date: "2011-09-06T13:46:05Z"
tags: []
categories: ["编程语言"]
slug: "element-type-quot-len-quot-must-be-followed-by-either-attribute-specifications-quot-gt-quot-or"
draft: false
lastmod: "2011-09-06T13:46:05Z"
id: 1166572
url: "https://bd2007.iteye.com/blog/1166572"
---

昨天在公司时，碰到个莫名其妙的bug，找了好久不知道原因，项目的框架是jsf、seam、利用facelet做视图模板，spring、hibernate。最后发现在js代码模块中，不能含有有“>”或“<”，比如下面的代码，for循环中有个“<”：

```js
var arr=[1,2,3];var len=arr.length;for(var i=0;i<len;++i){    alert(i);}
```
  
这样会被facelet解析成标签的开始，所以会提示“element type "len" must be followed by either attribute specifications, ">" or "/>"”。
解决方案：
把js代码中"<"换成"&amp;lt";把">"换成"&amp;gt;"