问题
I have this following problem in Netbeans IDE - when I create a JSP file and put these two taglibs inside
<%@taglib prefix="portlet" uri="http://java.sun.com/portlet_2_0" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
then I get error The absolute uri ... cannot be resolved
. So I am wondering where could be the problem?Application is working correctly when is deployed to AS but I would like to enjoy things like autocompletion during development. My pom.xml
looks like this - PasteBin.
I suppose I have all the necessary JARs on classpath so how can I make NetBeans to recognize those tags?
回答1:
To use sprint tags it enough to declare one spring dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
Spring downloads other dependencies automatically. All dependency list for spring portlet you can see here
With portlet tags a little more complicated, I still can't find dependency for portlet taglib and I always copy portlet_2_0.tld to my WEB-INF/tld folder, if you find this dependency let me know. Thanks.
回答2:
To fix the portlet TLD problem add this to your POM
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
The scope of provided is important - bear in mind you just want this to be included for validating in your IDE. The portlet TLD will be provided by whichever JSR-286 implementation you are deploying to e.g. Liferay, uPortal etc.
NB this worked for me in Eclipse, I presume it will also do the trick in NetBeans.
来源:https://stackoverflow.com/questions/14952102/maven-dependency-for-spring-and-portlet-tags