找不到 Spring Security 标签库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16099840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring Security taglib cannot be found
提问by Sy Z
When I put <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
当我放 <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
I will recieve the following error:
我会收到以下错误:
The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
But I have spring-security-taglibs-3.1.3et al in my /libfolder. Does anyone know what else am I missing?
但是我的/lib文件夹中有spring-security-taglibs-3.1.3等。有谁知道我还缺少什么?
回答by Mike R
Adding this dependency fixed it for me (using 3.1.X.RELEASE) :
添加此依赖项为我修复了它(使用 3.1.X.RELEASE):
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${your-version}</version>
</dependency>
The taglib now works properly:
taglib 现在可以正常工作:
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
回答by Kevin Bowersox
Make sure the following dependencies are included
确保包含以下依赖项
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.1.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.1.3.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
回答by Deepu Sahni
I am using jetty 9 (jetty-maven-plugin) The above could not help. So added below code to WEB-INF/web.xml and it worked like charm:
我用的是jetty 9 (jetty-maven-plugin) 上面的没用。所以将下面的代码添加到 WEB-INF/web.xml 中,它的作用就像魅力一样:
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspf</url-pattern>
<url-pattern>*.jspx</url-pattern>
<url-pattern>*.xsp</url-pattern>
<url-pattern>*.JSP</url-pattern>
<url-pattern>*.JSPF</url-pattern>
<url-pattern>*.JSPX</url-pattern>
<url-pattern>*.XSP</url-pattern>
</servlet-mapping>
Also add to jetty-context.xml of the problem still persists:
另外添加到jetty-context.xml的问题依然存在:
<Configure class="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>^$|.*/spring-[^/]*\.jar$|</Arg>
</Call>
</Configure>

