zhey 发表于 2017-4-27 17:00:36

Controller重复扫描

增加application.xml<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:cache="http://www.springframework.org/schema/cache"

       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       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
         http://www.springframework.org/schema/mvc
                http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                http://www.springframework.org/schema/cache
      http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
                http://cxf.apache.org/jaxws
                   http://cxf.apache.org/schemas/jaxws.xsd">
    <!-- ApplicationContext -->
    <bean class="org.jeecgframework.core.util.ApplicationContextUtil"></bean>
    <bean class="org.jeecgframework.p3.core.utils.common.ApplicationContextUtil"></bean>
    <import resource="spring-minidao.xml"/>
    <import resource="spring-mvc-*.xml"/>
    <!-- 智能表单配置引入 -->
    <import resource="classpath*:org/jeecgframework/web/cgform/common/spring-mvc-cgform.xml"/>
    <!-- jeecg plugin dev -->
    <import resource="classpath:config/spring-config-p3.xml"/>

</beans>
修改spring-mvc.xml,去掉application.xml中配置的内容:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
      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
         http://www.springframework.org/schema/mvc
                http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                http://cxf.apache.org/jaxws
                   http://cxf.apache.org/schemas/jaxws.xsd">
      <!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 -->
      <!-- 加载controller的时候,不加载service,因为此时事物并未生效,若此时加载了service,那么事物无法对service进行拦截 -->
      <context:component-scan base-package="org.jeecgframework.web.*,com.jeecg.*">
                <context:exclude-filter type="annotation"
                        expression="org.springframework.stereotype.Service" />
      </context:component-scan>


      <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
      <bean id="mappingJacksonHttpMessageConverter"
                class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
                <property name="supportedMediaTypes">
                        <list>
                              <value>text/html;charset=UTF-8</value>
                        </list>
                </property>
      </bean>
      <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射, 配置一个基于注解的定制的WebBindingInitializer,解决日期转换问题,方法级别的处理器映射 -->
      <bean
                class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
                <property name="cacheSeconds" value="0" />
                <property name="messageConverters">
                        <list>
                              <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
                        </list>
                </property>
                <property name="webBindingInitializer">
                        <bean class="org.jeecgframework.core.interceptors.MyWebBinding" />
                </property>
      </bean>
      <!-- 默认的视图解析器 在上边的解析错误时使用 (默认使用html)- -->
      <bean id="defaultViewResolver"
                class="org.springframework.web.servlet.view.InternalResourceViewResolver"
                p:order="3">
                <property name="viewClass"
                        value="org.springframework.web.servlet.view.JstlView" />
                <property name="contentType" value="text/html" />
                <property name="prefix" value="/webpage/" />
                <property name="suffix" value=".jsp" />
      </bean>
      <bean id="multipartResolver"
                class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
                p:defaultEncoding="UTF-8">
                <property name="maxUploadSize">
                        <value>104857600</value>
                </property>
                <property name="maxInMemorySize">
                        <value>4096</value>
                </property>
      </bean>

    <!-- Bean解析器,级别高于默认解析器,寻找bean对象进行二次处理 -->
    <bean id="beanNameViewResolver"
          class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0">
    </bean>
    <!-- Excel 处理 根据用户输入进行对象处理 -->
    <bean id="jeecgExcelView" class="org.jeecgframework.poi.excel.view.JeecgSingleExcelView" />
    <bean id="jeecgTemplateExcelView" class="org.jeecgframework.poi.excel.view.JeecgTemplateExcelView" />
    <bean id="jeecgTemplateWordView" class="org.jeecgframework.poi.excel.view.JeecgTemplateWordView" />
    <bean id="jeecgMapExcelView" class="org.jeecgframework.poi.excel.view.JeecgMapExcelView" />
      <!-- 方言 -->
      <bean id="dialect"
                class="org.jeecgframework.core.common.hibernate.dialect.DialectFactoryBean">
                <property name="dbType" value="${jdbc.dbType}" />
      </bean>
      <!-- 异常处理类 -->
      <bean id="exceptionHandler"
                class="org.jeecgframework.core.common.exception.GlobalExceptionResolver" />
      <!-- 拦截器 -->
      <mvc:interceptors>
                <mvc:interceptor>
                        <mvc:mapping path="/**" />
                        <bean class="org.jeecgframework.core.interceptors.EncodingInterceptor" />
                </mvc:interceptor>
                <mvc:interceptor>
                        <mvc:mapping path="/api/**" />
                        <bean class="org.jeecgframework.core.interceptors.SignInterceptor" />
                </mvc:interceptor>
                <!--add-end-dangzhenghui20170402 for 添加 api延签拦截器 对签名统处理-->
                <mvc:interceptor>
                        <mvc:mapping path="/**" />
                        <bean class="org.jeecgframework.core.interceptors.AuthInterceptor">
                              <property name="excludeUrls">
                                        <list>
                                                <value>loginController.do?goPwdInit</value>
                                                <value>loginController.do?pwdInit</value>
                                                <value>loginController.do?login</value>
                                                <value>loginController.do?logout</value>
                                                <value>loginController.do?changeDefaultOrg</value>
                        <value>loginController.do?login2</value>
                                                <value>loginController.do?login3</value>
                                                <value>loginController.do?checkuser</value>
                                                <value>loginController.do?checkuser=</value>
                                                <value>repairController.do?repair</value>
                                                <value>systemController.do?saveFiles</value>
                                                <value>repairController.do?deleteAndRepair</value>
                                                <value>userController.do?userOrgSelect</value>
                                                <!--移动图表-->
                                                <value>cgDynamGraphController.do?design</value>
                                                <value>cgDynamGraphController.do?datagrid</value>

                                                <!-- 菜单样式图标预览 -->
                                                <value>webpage/common/functionIconStyleList.jsp</value>
                                        </list>
                              </property>
                        </bean>
                </mvc:interceptor>
      </mvc:interceptors>

</beans>修改web.xml:<context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath*:application.xml</param-value>
      </context-param>

admin 发表于 2017-4-28 09:13:04

??啥意思
页: [1]
查看完整版本: Controller重复扫描