午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

java - SSH框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類

瀏覽:237日期: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);// 當(dāng)前多少頁(yè)int pageSize = 3;pageUntil.setPagesize(pageSize);// 最多顯示多少記錄int totalCount = iauthoradmindao.findCount();// 數(shù)據(jù)庫(kù)中所有的記錄pageUntil.setTotalCount(totalCount);double tc = totalCount;Double num = Math.ceil(tc / pageSize);// 頁(yè)面顯示的總頁(yè)數(shù)=數(shù)據(jù)庫(kù)的總記錄數(shù)/最多顯示多少記錄pageUntil.setTotalPage(num.intValue());int begin = (currentPage - 1) * pageSize;// 當(dāng)前頁(yè)開頭位置的索引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框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類

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框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類java - SSH框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類

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

問題解答

回答1:

PageUntil這個(gè)類也是要用@Component

回答2:

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

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

回答3:

我覺得 new出來(lái)最簡(jiǎn)單了。你這個(gè)類需要考慮到特殊的問題嗎?

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 在线久久| 欧美性生活一级片 | 超碰手机在线观看 | 午夜超碰 | 男人的天堂视频在线 | 亚洲精品久久久久久久久 | 蜜色视频 | 久久精品99国产国产精 | 久色视频在线 | 国产日日日 | 色多多污污 | 亚洲国产精品成人综合色在线婷婷 | 狠狠干综合网 | av福利网| 欧美亚洲专区 | 亚洲天天 | 97久久国产 | 免费av在线网站 | 欧美一区二区在线观看视频 | 91福利视频在线观看 | 国产9区 | 亚洲精品久久久久 | 国产精品免费精品一区 | 婷婷色中文字幕 | 国产99久久久欧美黑人 | 国产精品国产精品国产专区 | 国产一区二区三区免费观看 | 欧美黄色一区 | 欧美一区视频 | 久久久久一区二区三区四区 | 国产又粗又黄又爽的视频 | 亚洲精品久久久久国产 | 国内特级毛片 | 99成人免费视频 | 91精品国产乱码久久久 | 国产黄色片子 | 李宗瑞91在线正在播放 | 一区二区视频网站 | 日本天天色 | 91禁直接看 | 91蝌蚪在线 |