2

我有一个下面定义的弹簧注释类

@component   
public class FormFilter extends DroplistFilterEditor{    

   @Autowire   
   private PersonService personService;

   @Override
   protected List<Option> getOptions()
   {
      List<Option> options = new ArrayList<Option>();
      try {
         String fieldName = getColumn().getProperty();
         List<StudyListView> studyList = null;
         studyList=personService.findList();
         for(StudyListView study:studyList){
           options.add(new Option(study.getId(),study.getDesc()));
         }       
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     return options;
   }
}

我正在尝试从 jsp 调用此类以在页面加载时显示下拉列表。我们正在使用 jMesa 进行表格渲染。

当应用程序正在部署时,上面的类被加载,但是当它从 jsp 调用时,personService 对象为空。自动装配没有发生。

我是 Spring MVC 和 jMesa 的新手。任何帮助表示赞赏。提前致谢。

应用配置文件

@Configuration
@Import({
AppTilesConfig.class,
AppWebConfig.class,
AppJpaConfig.class,
})

@ComponentScan(basePackages = {
    "com.service",
    "com.controller",
    "com.web.ui",
  })
public class AppConfig {
    // This class is a root to import all dependent configurations.
}

对于 Spring mvc (AppWebConfig) 我有下面的类

@Configuration
@EnableWebMvc
public class AppWebConfig {

@Bean
public ReloadableResourceBundleMessageSource messageSource()
{
    ReloadableResourceBundleMessageSource messageSource = new     ReloadableResourceBundleMessageSource();
    String[] resources = {"classpath:messages"};
    messageSource.setBasenames(resources);
    return messageSource;
  }
}

找到页面加载时调用FormFilter的jsp代码

<jmesa:springTableFacade id="imageTableId" items="${imageList}"
                    stateAttr="restore" var="item" exportTypes="" editable="false" rowFilter=""
                    toolbar="com.bar.FullPaginationToolBar">
                    <jmesa:htmlRow uniqueProperty="rowId" rowRenderer="com.bar.CustomHtmlRowRenderer"><jmesa:htmlTable><jmesa:htmlColumn property="study" style="white-space: nowrap" title="Study" editable="false" filterable="true" filterEditor="com.web.ui.FormFilter" sortable="true" /></jmesa:htmlRow></jmesa:springTableFacade>
4

0 回答 0