解析XHTML时出错:元素的内容必须由格式良好的字符数据或标记组成
在列表框中获取所选项目并将其转换为要在JSF中使用的参数FileServlet
。即para2=value1¶m=value2¶m=value3
这就是我所拥有的:
<script type ="text/javascript">function myScript() { var box = document.getElementbyId('myForm:box'); var length = box.options.length; var paramstring = ""; for (var i = 0; i < length; i++) { if (i != (length - 1) { if (box.options[i].selected) { paramstring = paramstring + "param=" + box.options[i].value + "&"; } } else { paramstring = paramstring + "param=" + box.options[i].value; } } if (document.getElementById('myForm:checkbox').checked) { window.location='fileServlet? + paramstring; }}</script>
加载页面时得到的结果: javax.servlet.ServletException: Error Parsing /page.xhtml: Error Traced[line:15] The content of elements must consist of well-formed character data or markup.
什么不会触发异常:
<script type ="text/javascript">function myScript() { var box = document.getElementbyId('myForm:box'); var length = box.options.length; var paramstring = ""; if (document.getElementById('myForm:checkbox').checked) { window.location='fileServlet? + paramstring; }}</script>
只要我加入for (var i = 0; i < length; i++)
甚至for (var i = 0; i < 10; i++)
页面都不会加载。为什么它不喜欢for循环?
肥皂起泡泡
精慕HU
达令说