国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

java - SSH框架中寫分頁時service層中不能注入分頁類

瀏覽:73日期:2023-11-08 08:00:02

問題描述

service層

@Servicepublic class AuthorAdminServiceImpl implements IAuthorAdminService { @Resource private IAuthorAdminDao iauthoradmindao; @Resource PageUntil<AuthorAdmin> pageUntil;@Override public PageUntil<AuthorAdmin> findByPage(int currentPage) {pageUntil.setCurrentPage(currentPage);// 當前多少頁int pageSize = 3;pageUntil.setPagesize(pageSize);// 最多顯示多少記錄int totalCount = iauthoradmindao.findCount();// 數據庫中所有的記錄pageUntil.setTotalCount(totalCount);double tc = totalCount;Double num = Math.ceil(tc / pageSize);// 頁面顯示的總頁數=數據庫的總記錄數/最多顯示多少記錄pageUntil.setTotalPage(num.intValue());int begin = (currentPage - 1) * pageSize;// 當前頁開頭位置的索引List<AuthorAdmin> list = iauthoradmindao.findByPage(begin, pageSize);if(list==null){ System.out.println('list findByPage service error');}pageUntil.setList(list);return pageUntil; }

action層

public String listAuthorAdmin() {PageUntil<AuthorAdmin> pageuntil = iauthoradminservice.findByPage(currentPage);ActionContext.getContext().getValueStack().push(pageuntil);return 'listSuccess'; }

java - SSH框架中寫分頁時service層中不能注入分頁類

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ’authorAdminAction’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ’authorAdminServiceImpl’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.lcy.until.PageUntil com.lcy.service.author.admin.AuthorAdminServiceImpl.pageUntil; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}----------Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ’authorAdminServiceImpl’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.lcy.until.PageUntil com.lcy.service.author.admin.AuthorAdminServiceImpl.pageUntil; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}----------Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.lcy.until.PageUntil com.lcy.service.author.admin.AuthorAdminServiceImpl.pageUntil; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}----------Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

java - SSH框架中寫分頁時service層中不能注入分頁類java - SSH框架中寫分頁時service層中不能注入分頁類

如果不是使用注入而使用new的方法就行,請問為什么?

問題解答

回答1:

PageUntil這個類也是要用@Component

回答2:

你沒有正確使用@Resource,導致配置文件里面找不到名稱屬性為'iauthoradmindao'的<bean>,故而注入失敗!你可以將@Resource 更換成 @AutoWired 試試看。這兩個注解的注入方式是不一樣的,當然前提是你的xml文件中要配有'IAuthorAdminDao '類型的<bean>

詳情參考:https://www.zhihu.com/questio...

回答3:

我覺得 new出來最簡單了。你這個類需要考慮到特殊的問題嗎?

標簽: java
相關文章:
主站蜘蛛池模板: 亚洲三级网 | 欧美激情精品久久久久久久久久 | 精品国产亚洲一区二区三区 | 日韩高清免费观看 | 成人永久福利在线观看不卡 | 久草在线最新视频 | 特级aaa片毛片免费观看 | 国产免费一区二区三区在线观看 | 国产一区二区三区在线观看免费 | 全国男人的天堂天堂网 | 男人天堂视频网 | 2020精品极品国产色在线观看 | 久久国产精品免费视频 | 18视频免费网站 | 亚洲精品一区二区三区www | 特级a欧美做爰片毛片 | 一级毛片免费观看 | 久久精品精品 | 日本三级网站 | 久久久久免费视频 | a在线观看欧美在线观看 | 久久国产视频网 | 久久久久久91香蕉国产 | 亚洲精品欧美精品一区二区 | 国外免费一级 | 韩国一级做a爰片性色毛片 韩国一区在线 | 亚洲视频在线观看免费 | 日韩美a一级毛片 | 国产成人lu在线视频 | 99久久免费国产精精品 | 一本色道久久综合亚洲精品高清 | 欧美男人操女人 | 国产成人免费福利网站 | 日本免费一区二区三区视频 | 欧美在线视频一区二区 | 美女视频黄的免费看网站 | 国产成人在线综合 | 精品国产看高清国产毛片 | 欧美视频亚洲视频 | 天堂mv亚洲mv在线播放9蜜 | 国产91精品一区二区麻豆亚洲 |