JSP JSTL标签 Unterminated <c:when tag错误要疯了。

CapJes 发布于 2018/05/01 22:13
阅读 613
收藏 0

使用JSP的JSTL标签,不知道什么原因导致forEach标签和choose标签无法检测到结束。

我能确定这两个标签都是正常结束的。

下面的forEach choose when标签逐个删除都报错。这样的写法,我用在了多个项目中,都没有出现这个问题,这次掉坑里了。完全不知道错在什么地方。

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/comm/jstl.jsp" %>
		<form class="form-horizontal form-bordered" role="form" method="post" action="${actionUrl}">
			<div class="form-group">
				<label for="txtBrandNo" class="col-sm-2 control-label no-padding-right">品牌</label>
				<div class="col-sm-10">
					<select name="brandId" class="form-control" id="selectBrandId" data-rule="required;">
						<option value="">请选择品牌</option>
						<c:forEach items="${brands}" var="brand">
							<c:choose>
								<c:when test="${brand.brandId==model.brandId}">
									<option value="${brand.brandId" selected>${brand.brandName}</option>
								</c:when>
								<c:otherwise>
									<option value="${brand.brandId">${brand.brandName}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select>
		        </div>
		        <span class="msg-box" for="selectBrandId"></span>
			</div>
		 	<div class="form-group">
		         <label for="txtBrandNo" class="col-sm-2 control-label no-padding-right">型号编号</label>
		         <div class="col-sm-10">
		             <input type="text" class="form-control" id="txtModelNo" placeholder="品牌编号" data-rule="required;" value="${model.modelNo}">
		         </div>
		         <span class="msg-box" for="txtModelNo"></span>
		     </div>
		     <div class="form-group">
		          <label for="txtBrandName" class="col-sm-2 control-label no-padding-right">型号名称</label>
		          <div class="col-sm-10">
		              <input type="text" class="form-control" id="txtModelName" placeholder="品牌名称" data-rule="required;" value="${model.modelName}">
		          </div>
		          <span class="msg-box" for="txtModelName"></span>
		      </div>
		      <div class="form-group">
		          <div class="col-sm-offset-2 col-sm-10">
		              <button type="submit" class="btn btn-palegreen">提交</button>
		          </div>
		      </div>
		</form>

错误日志:
 


2018-05-01 22:08:56 ERROR [http-bio-8080-exec-9] com.jfinal.core.ActionHandler  - /models/toDoAction
com.jfinal.render.RenderException: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: /admin/product/modelForm.jsp (line: 42, column: 2) Unterminated &lt;c:when tag
	at com.jfinal.render.JspRender.render(JspRender.java:69)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:97)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: /admin/product/modelForm.jsp (line: 42, column: 2) Unterminated &lt;c:when tag
	at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
	at com.jfinal.render.JspRender.render(JspRender.java:67)
	... 18 more
Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: /admin/product/modelForm.jsp (line: 42, column: 2) Unterminated &lt;c:when tag
	at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:908)
	at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
	at org.apache.jsp.admin.product.modelAdd_jsp._jspService(modelAdd_jsp.java:144)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
	... 31 more
Caused by: org.apache.jasper.JasperException: /admin/product/modelForm.jsp (line: 42, column: 2) Unterminated &lt;c:when tag
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:133)
	at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1677)
	at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1002)
	at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1274)
	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1452)
	at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1664)
	at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1002)
	at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1274)
	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1452)
	at org.apache.jasper.compiler.Parser.parseBody(Parser.java:1664)
	at org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1002)
	at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1274)
	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1452)
	at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
	at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
	at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
	at org.apache.taglibs.standard.tag.common.core.ImportSupport.acquireString(ImportSupport.java:314)
	at org.apache.taglibs.standard.tag.common.core.ImportSupport.doEndTag(ImportSupport.java:171)
	at org.apache.jsp.admin.product.modelAdd_jsp._jspx_meth_c_005fimport_005f2(modelAdd_jsp.java:334)
	at org.apache.jsp.admin.product.modelAdd_jsp._jspService(modelAdd_jsp.java:123)
	... 34 more

 

加载中
0
爱蔚兰真好
otherwise|option|value 少了 }
清帝
清帝
确实少了个右大括号
0
龙影
龙影
天啊,居然还在用JSP
龙影
龙影
我个人觉得还是抛弃JSP这种在服务器上做html生成的方式,毕竟服务器资源有限,让服务器专注于业务逻辑处理。
暗中观察
暗中观察
jsp性能好,你有不同意见吗?
0
CapJes
CapJes

引用来自“爱蔚兰真好”的评论

otherwise|option|value 少了 }

哈哈,局外人就是清醒。这个问题我搞了3~4个小时了。到现在我也不知道问题出在什么地方,后来我把代码重新写了一遍,才恢复了。不过现在看你答案却是是这个原因。多谢。

龙影
龙影
汗,确实不应该发生的错误。这个是编码习惯造成的。论好习惯的重要性。
0
CapJes
CapJes

引用来自“龙影”的评论

天啊,居然还在用JSP

嗯,不要对JSP有什么偏见好吧,使用什么技术都是解决实际的项目问题,怎么合适便捷怎么来,没必要最求高大上。再者,JSP也没有你说的那么不堪,还有现在项目服务器的配置基本都有80%~90%都是冗余浪费的,没必要太在意服务器的资源耗费的问题。

龙影
龙影
@CapJes 回复@CapJes : 这就得要看领导是否有那协调能力了,前后端分离,其实对设计者要求会更高些。但是对于软件来说是好事。对应好接口来开发何尝不是件好事?so,先定义好合理的接口。
龙影
龙影
@CapJes 回复@CapJes : 没说前后分离就必须分工到两种人。这个看前后端选型及搭配是否适合一个人同时做。反正我现在的方式一个人全包。因为简单,培训下组员,很快上手开发。
CapJes
CapJes
回复 @龙影 : 一个人做前后全包了,去做前后分离,反而麻烦。
龙影
龙影
回复@CapJes : 也不是说它不好,只是说要看如何使用。毕竟现在前端技术那么多可以选择。开发效率和综合性能方面来考量选择的。
返回顶部
顶部