main
wangxiaotong111 1 week ago
parent 6ec00f4f82
commit 72b2fc96f1

@ -37,6 +37,20 @@
<property name="publishTime" value="2026-04-09 14:00:00"/>
<property name="status" value="1"/>
</bean>
<!-- ====================== 我的轮播列表模块(新增) ====================== -->
<bean id="carousel" class="com.ssm.ioc.Carousel">
<property name="id" value="1"/>
<property name="title" value="首页轮播1"/>
<property name="imgUrl" value="/images/banner1.jpg"/>
<property name="linkUrl" value="/index"/>
<property name="sort" value="1"/>
</bean>
<bean id="carousel2" class="com.ssm.ioc.Carousel">
<property name="id" value="2"/>
<property name="title" value="首页轮播2"/>
<property name="imgUrl" value="/images/banner2.jpg"/>
<property name="linkUrl" value="/activity"/>
<property name="sort" value="2"/>
</bean>
</beans>

@ -0,0 +1,45 @@
package com.ssm.ioc;
public class Carousel {
// 轮播ID
private Integer id;
// 轮播标题
private String title;
// 轮播图片地址
private String imgUrl;
// 轮播跳转链接
private String linkUrl;
// 轮播排序(数字越小越靠前)
private Integer sort;
// Spring IoC必须无参构造
public Carousel() {}
// 必须完整Getter&Setter用于属性注入
public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; }
public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }
public String getImgUrl() { return imgUrl; }
public void setImgUrl(String imgUrl) { this.imgUrl = imgUrl; }
public String getLinkUrl() { return linkUrl; }
public void setLinkUrl(String linkUrl) { this.linkUrl = linkUrl; }
public Integer getSort() { return sort; }
public void setSort(Integer sort) { this.sort = sort; }
// 用于打印对象信息
@Override
public String toString() {
return "Carousel{" +
"id=" + id +
", title='" + title + '\'' +
", imgUrl='" + imgUrl + '\'' +
", linkUrl='" + linkUrl + '\'' +
", sort=" + sort +
'}';
}
}

@ -25,6 +25,10 @@ public class Testioc {
Announcement announcement = context.getBean("announcement", Announcement.class);
//直接打印对象
System.out.println("公告信息:" + announcement);
// ====================== 我的轮播列表(新增,不影响他人) ======================
Carousel carousel1 = context.getBean("carousel", Carousel.class);
System.out.println("\n===== 我的轮播列表信息 =====");
System.out.println(carousel1);
}

@ -37,6 +37,20 @@
<property name="publishTime" value="2026-04-09 14:00:00"/>
<property name="status" value="1"/>
</bean>
<!-- ====================== 我的轮播列表模块(新增) ====================== -->
<bean id="carousel" class="com.ssm.ioc.Carousel">
<property name="id" value="1"/>
<property name="title" value="首页轮播1"/>
<property name="imgUrl" value="/images/banner1.jpg"/>
<property name="linkUrl" value="/index"/>
<property name="sort" value="1"/>
</bean>
<bean id="carousel2" class="com.ssm.ioc.Carousel">
<property name="id" value="2"/>
<property name="title" value="首页轮播2"/>
<property name="imgUrl" value="/images/banner2.jpg"/>
<property name="linkUrl" value="/activity"/>
<property name="sort" value="2"/>
</bean>
</beans>
Loading…
Cancel
Save