使用Eclipse EE开发web项目

最近使用EclipseEE开发web项目,遇到了以下几个问题:

1. 通过tomcat启动web应用的时候,总是提示找不到包或者class。

经过排查,发现所有的jar包并没有放到WEB-INF/lib中,于是只能手动的把包放到lib中。

2.jstl使用不了,在jsp文件中添加taglib总是报错。

解决方式:首先,下载jstl.jar,并复制到WEB-INF/lib中,然后在web.xml中添加taglib的配置

<jsp-config>
		<taglib>
			<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
			<taglib-location>/WEB-INF/fmt.tld</taglib-location>
		</taglib>

		<taglib>
			<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
			<taglib-location>/WEB-INF/c.tld</taglib-location>
		</taglib>

		<taglib>
			<taglib-uri>http://java.sun.com/jstl/perTag</taglib-uri>
			<taglib-location>/WEB-INF/permittedTaglibs.tld</taglib-location>
		</taglib>

		<taglib>
			<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
			<taglib-location>/WEB-INF/sql.tld</taglib-location>
		</taglib>

		<taglib>
			<taglib-uri>http://java.sun.com/jstl/script</taglib-uri>
			<taglib-location>/WEB-INF/scriptfree.tld</taglib-location>
		</taglib>

		<taglib>
			<taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
			<taglib-location>/WEB-INF/x.tld</taglib-location>
		</taglib>

	</jsp-config>

至此,解决。


以前用myeclipse开发web项目,myeclipse帮助我们把引用的jar包放到项目(实际上是tomcat的webapps中的项目)的lib中。至此,终于理解了在JSP2规范中增加jsp配置的作用了。

原文地址:https://www.cnblogs.com/javawebsoa/p/3196768.html