在 IDEA上使用 maven创建 web骨架项目,在 pom文件中添加 jstl依赖
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
此时,创建 jsp页面,并且使用 <c:forEach/>
标签可能会报错如下:
org.apache.jasper.JasperException: /pages/product-list.jsp (line: [214], column: [28]) According to TLD or attribute directive in tag file, attribute [items] does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:291)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1242)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:880)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1545)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2444)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2450)
org.apache.jasper.compiler.Node$Root.accept(Node.java:471)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1854)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:221)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:335)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:595)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:171)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
解决措施:
在 structure中的lib包下添加 jstl的 jar包
尽管有 maven的依赖,idea也不会自动添加,需要用户手动添加
类似的,如果在 idea上不使用骨架创建 web项目,却想要把空项目变成 web项目,则可以手动添加 web
注意:
以这种方式添加 web功能后,如果要发布,idea不会自动把依赖 jar包添加到 lib文件夹中,需要以类似处理 jstl问题的方式解决。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章