2013-05-09 101 views
1

我想集成Springsecurity,struts2和tiles3,一旦我运行我的应用程序,它会遇到以下错误,请让我知道如果我应该包含我的代码的任何其他部分。如何集成Spring-security,struts2和tiles3

Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.view.tiles3.tilesConfigurer] for bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.tiles3.tilesConfigurer. Please see server.log for more details. 
The module has not been deployed. 
See the server log for details. 
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210) 
    at org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178) 
    at 
    org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130) 
    at 
    org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212) 
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153) 

根据这个问题Spring不支持Tiles3是否正确? Question

的applicationContext.xml

<?xml version='1.0' encoding='UTF-8'?> 
    <beans xmlns='http://www.springframework.org/schema/beans' 
        xmlns:context='http://www.springframework.org/schema/context' 
        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
        xsi:schemaLocation='http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
      http://www.springframework.org/schema/context  
     http://www.springframework.org/schema/context/spring-context-3.0.xsd'> 

     <context:component-scan base-package='com.MyProject'/> 
     <bean id='internalResourceResolver' 
        class='org.springframework.web.servlet.view.InternalResourceViewResolver'> 
      <property name='prefix' value='/Web Pages/'/> 
      <property name='suffix' value='.jsp'/> 
     </bean> 
     <bean 
     class='org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping'/> 
     <bean 
     class='org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter'/> 
     <bean id='placeholderConfig' 

      class='org.springframework.beans.factory.config.PropertyPlaceholderConfigurer'/> 

     <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
     <property name="viewClass"> 
      <value> 
       org.springframework.web.servlet.view.tiles3.tileviewresolver 
      </value> 
     </property> 
    </bean> 
     <bean id="tilesConfigurer" 
      class="org.springframework.web.servlet.view.tiles3.tilesConfigurer"> 
     <property name="definitions"> 
      <list> 
       <value>/WEB-INF/tiles.xml</value> 
      </list> 
     </property> 
    </bean> 
    </beans> 

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web- 
    app_3_0.xsd"> 
     <context-param> 
      <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name> 
      <param-value>/WEB-INF/tiles.xml</param-value> 
     </context-param> 
     <listener> 
     <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener- 
     class> 
     </listener> 
      <listener> 
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener- 
       class> 
     </listener> 
     <context-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value> 
       /WEB-INF/applicationContext.xml 
       /WEB-INF/myProject-security.xml 
       /WEB-INF/login-service.xml 
      </param-value> 
     </context-param> 
     <filter> 
      <filter-name>springSecurityFilterChain</filter-name> 
      <filter-class> 
       org.springframework.web.filter.DelegatingFilterProxy 
      </filter-class> 
     </filter> 

     <filter-mapping> 
      <filter-name>springSecurityFilterChain</filter-name> 
      <url-pattern>/*</url-pattern> 
     </filter-mapping> 
     <filter> 
      <filter-name>struts2</filter-name> 
      <filter-  
     class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter- 
      class> 
     </filter> 
     <filter-mapping> 
      <filter-name>struts2</filter-name> 
      <url-pattern>/*</url-pattern> 
     </filter-mapping> 
     <session-config> 
      <session-timeout> 
       30 
      </session-timeout> 
     </session-config> 
     <welcome-file-list> 
      <welcome-file>index.jsp</welcome-file> 
     </welcome-file-list> 
    </web-app> 

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema- 
    instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven- 
     4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.myproject</groupId> 
    <artifactId>MyProject</artifactId> 
    <version>1.0</version> 
    <packaging>war</packaging> 

    <name>MyProject</name> 

    <properties> 
     <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <glassfish.embedded-static-shell.jar>C:\Program 
     Files\Java\jre7\bin\glassfish\lib\embedded\glassfish-embedded-static- 
     shell.jar</glassfish.embedded-static-shell.jar> 
     <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.apache.struts</groupId> 
      <artifactId>struts2-core</artifactId> 
      <version>2.3.8</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-fileupload</groupId> 
      <artifactId>commons-fileupload</artifactId> 
      <version>1.2.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.mortbay.jetty</groupId> 
      <artifactId>jsp-2.1-glassfish</artifactId> 
      <version>9.1.02.B04.p0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.struts</groupId> 
      <artifactId>struts2-convention-plugin</artifactId> 
      <version>2.3.14</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.struts</groupId> 
      <artifactId>struts2-dojo-plugin</artifactId> 
      <version>2.3.14</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.struts</groupId> 
      <artifactId>struts-taglib</artifactId> 
      <version>1.3.10</version> 
     </dependency> 
     <dependency> 
      <groupId>jdbc</groupId> 
      <artifactId>jdbc-stdext</artifactId> 
      <version>2.0</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>javax.sql</groupId> 
      <artifactId>jdbc-stdext</artifactId> 
      <version>2.0</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.extras</groupId> 
      <artifactId>glassfish-embedded-static-shell</artifactId> 
      <version>3.1.1</version> 
      <scope>system</scope> 
      <systemPath>${glassfish.embedded-static-shell.jar}</systemPath> 
     </dependency> 
     <dependency> 
      <groupId>com.kenai.nbpwr</groupId> 
      <artifactId>org-apache-commons-dbcp</artifactId> 
      <version>1.2.2-201002241055</version> 
      <type>nbm</type> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.24</version> 
     </dependency> 
      <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>3.0.7.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-web</artifactId> 
      <version>3.0.7.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-core</artifactId> 
      <version>3.0.7.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-taglibs</artifactId> 
      <version>3.0.7.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-config</artifactId> 
      <version>3.0.7.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-dbutils</groupId> 
      <artifactId>commons-dbutils</artifactId> 
      <version>1.5</version> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>struts</groupId> 
      <artifactId>struts</artifactId> 
      <version>1.2.9</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.taglibs</groupId> 
      <artifactId>taglibs-parent</artifactId> 
      <version>3</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>com.itextpdf</groupId> 
      <artifactId>itextpdf</artifactId> 
      <version>5.3.2</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.zxing</groupId> 
      <artifactId>javase</artifactId> 
      <version>1.7</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.zxing</groupId> 
      <artifactId>core</artifactId> 
      <version>1.7</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.xml</groupId> 
      <artifactId>jaxrpc</artifactId> 
      <version>1.1</version> 
      <type>pom</type> 
     </dependency> 
     <dependency> 
      <groupId>taglibs</groupId> 
      <artifactId>fmt</artifactId> 
      <version>1.1.2</version> 
      <type>tld</type> 
     </dependency> 
     <dependency> 
     <groupId>commons-beanutils</groupId> 
     <artifactId>commons-beanutils</artifactId> 
     <version>1.8.0</version> 
     </dependency> 
     <dependency> 
    <groupId>commons-digester</groupId> 
    <artifactId>commons-digester</artifactId> 
    <version>2.0</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-io</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>1.3.2</version> 
     </dependency> 
     <dependency> 
      <groupId>net.sf.opencsv</groupId> 
      <artifactId>opencsv</artifactId> 
      <version>2.3</version> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.struts</groupId> 
      <artifactId>struts2-tiles3-plugin</artifactId> 
      <version>2.3.14</version> 
     </dependency> 
     <dependency> 
      <groupId>javax</groupId> 
      <artifactId>javaee-web-api</artifactId> 
      <version>6.0</version> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>axis</groupId> 
      <artifactId>axis</artifactId> 
      <version>1.4</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-discovery</groupId> 
      <artifactId>commons-discovery</artifactId> 
      <version>0.2</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-logging</groupId> 
      <artifactId>commons-logging</artifactId> 
      <version>1.1.1</version> 
     </dependency> 
      <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>1.5.6</version> 
     </dependency> 
    <dependency> 
<groupId>log4j</groupId> 
<artifactId>log4j</artifactId> 
<version>1.2.15</version> 
<exclusions> 
    <exclusion> 
     <groupId>com.sun.jmx</groupId> 
     <artifactId>jmxri</artifactId> 
    </exclusion> 
    <exclusion> 
     <groupId>com.sun.jdmk</groupId> 
     <artifactId>jmxtools</artifactId> 
    </exclusion> 
    <exclusion> 
      <groupId>javax.jms</groupId> 
      <artifactId>jms</artifactId> 
    </exclusion> 
</exclusions> 
</dependency> 
      <dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-api</artifactId> 
    <version>1.5.6</version> 
</dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <compilerArguments> 
         <endorseddirs>${endorsed.dir}</endorseddirs> 
        </compilerArguments> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.1.1</version> 
       <configuration> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.1</version> 
       <executions> 
        <execution> 
         <phase>validate</phase> 
         <goals> 
          <goal>copy</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${endorsed.dir}</outputDirectory> 
          <silent>true</silent> 
          <artifactItems> 
           <artifactItem> 
            <groupId>javax</groupId> 
            <artifactId>javaee-endorsed-api</artifactId> 
            <version>6.0</version> 
            <type>jar</type> 
           </artifactItem> 
          </artifactItems> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

回答

2

我想我明白了...

我不是特别了解春季安全。不考虑它,这是一般的流程:

请求 - > struts2的解析和执行动作 - >呈现视图(其将有时是瓦片结果)

甲瓷砖的结果应该被认为是一个视图。瓷砖可以让你将意见排除在意见之外,但在一天结束时,它只是一个视图。

当使用spring安全性时,通常在Web应用程序中保护每个jsp? 如果不是那么我不会尝试保证瓷砖视图。

取而代之的是确保struts2的动作...因为如果某些东西不安全,动作仍然会执行,并且可能会发生不好的事情。因此,阻止链条上的“坏事”。

如果这是有道理的,那么你不需要applicationContext.xml中的任何基于图块的东西(只是摆脱它)。当然这个错误是因为它无法解决课程而发生的,但我有一种感觉,这个课程真的是用于spring-mvc集成,所以只是忘了它。

如果按照tiles3-插件集成指南那么你的web.xml文件中包含:

<listener> 
    <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class> 
</listener> 

这将加载所需的struts2-tiles3结果呈现的一切。

+0

它现在的作品,现在我应该打开一个新的问题菜单的东西? – J888 2013-05-09 03:45:29

+0

对不起,是的。评论太短...迪斯科。 – Quaternion 2013-05-09 03:55:43

+0

好的新问题在这里http://stackoverflow.com/questions/16454135/how-to-provide-different-menu-according-to-rule-of-user – J888 2013-05-09 04:03:00