SSH项目耦合性的问题
下面是老师给的一个完整的项目中的一个ACTION 项目用的是STRUTS2+SPRING+HIBERNATE 就是SSH做的
我是初学者 我经常听说SSH是为解耦合 但是这个ACTION里面导入了这么多包 会增加耦合性吗?
正确的做法 应该不会导入这么多包的吧?应该使用SPRING注入的吧?求高手打开心结
package com.ruanko.classmate.groups.control.action;
import java.util.List;
import com.ruanko.classmate.base.BaseAction;
import com.ruanko.classmate.groups.dao.entity.GroupMember;
import com.ruanko.classmate.groups.dao.entity.GroupType;
import com.ruanko.classmate.groups.dao.entity.Groups;
import com.ruanko.classmate.groups.service.iface.IGroupManageService;
import com.ruanko.classmate.groups.service.iface.IGroupService;
import com.ruanko.classmate.individual.dao.entity.Users;
public class GroupAction extends BaseAction {
private int groupId;
private String groupName;
private String description;
private Groups groups;
private GroupType groupType;
private int currentPage;
private int pageCount;
private int totalCount;
private String keyword;
private List<Groups> groupList;
private IGroupService groupService;
private IGroupManageService groupManageService;
public String groupList() {
try {
if (currentPage == 0)
currentPage = 1;
int pageSize = 5;
totalCount = this.groupService.getTotalCount();
pageCount = this.groupService.getPageCount(pageSize);
if (currentPage > pageCount)
currentPage = pageCount;
groupList = this.groupService
.findCurrentPage(currentPage, pageSize);
} catch (Exception e) {
e.printStackTrace();
}
return SUCCESS;
}
public String enterGroup() {
try {
this.session.remove("currentGroup");
this.session.remove("memberShip");
int flag = 0;
this.groups = this.groupService.findById(groupId);
this.session.put("currentGroup", this.groups);
Integer accessTimes = groups.getAccessTimes();
if (accessTimes == null)
accessTimes = 1;
accessTimes++;
groups.setAccessTimes(accessTimes);
groupService.updateGroups(groups);
Users currentUser = (Users) session.get(super.USER);
if (currentUser != null) {
this.session.put("memberShip", this.groupManageService
.findGroupMember(currentUser, groupId));
}
} catch (Exception e) {
e.printStackTrace();
}
return SUCCESS;
}
public void judgeUserStatus() {
if (this.session.get(BaseAction.USER) != null) {
if (isInGroup() == true) {
this.session.put("memberStatus", 1);
if (isManager() == true) {
this.session.put("flag4Manage", 1);
} else
this.session.put("flag4Manage", 0);
}
}
}
public boolean isInGroup() {
Users user = (Users) this.session.get(BaseAction.USER);
return groupManageService.isInGroup(user, groupId);
}
public boolean isManager() {
Users user = (Users) this.session.get(BaseAction.USER);
return groupManageService.isManager(user, groupId);
}
public String findGroup() {
groupList = this.groupService.findByKeyword(keyword);
return SUCCESS;
}
public int getGroupId() {
return groupId;
}
public void setGroupId(int groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Groups getGroups() {
return groups;
}
public void setGroups(Groups groups) {
this.groups = groups;
}
public GroupType getGroupType() {
return groupType;
}
public void setGroupType(GroupType groupType) {
this.groupType = groupType;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getPageCount() {
return pageCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public List<Groups> getGroupList() {
return groupList;
}
public void setGroupList(List<Groups> groupList) {
this.groupList = groupList;
}
public void setGroupService(IGroupService groupService) {
this.groupService = groupService;
}
public void setGroupMamageService(IGroupManageService groupMamageService) {
this.groupManageService = groupMamageService;
}
}