在线求大佬指导
框架编程技术的实验作业,因为几乎没学。。。。emmm
使用eclipse、SQL Server软件实现,希望回答具体操作流程,包括连接数据库的过程,越详细越好,万分感谢!
现要通过Struts2+Spring+Hibernate技术实现员工信息展示,在点击超链接“显示学生信息”后,网页界面employeeList.jsp显示如下图:
ID 员工姓名 基本工资 出生日期 籍贯
1 张凤 3800 1965/11/28 山东青岛
2 李斯 3500 1970/05/12 山东日照
3 王平 3000 1972/01/08 山东潍坊
4 邹域 2600 1983/10/17 山东济南
(题目中为表格形式)
后台数据库表employeeTable如下:
字段 类型 说明
id int 主键
employeeName varchar(80) 员工姓名
salary int 基本工资
birthday datetime 出生日期
place varchar(100) 籍贯
(题目中为表格形式)
1.请写出对应的实体类com.dh.entity.Employee
2.点击超链接,进入EmployeeAction,关键代码如下:
<a href=" employee.action">显示学生信息</a>
3.在对应的com.dh.action. EmployeeAction中已经获得相关的数据
public class EmployeeAction {
private List<Employee> employees;
private EmployeeService employeeService;
public String execute(){
employees= employeeService.getAllEmployees();
return "showEmployees";
}
public List<Employee> getEmployees () {
return employees;
}
public void setEmployees(List<Empolyee> employees) {
this.employees= employees;
}
public void setEmployeeService(EmployeeService employeeService) {
this.employeeService = employeeService;
}
}
4.Spring配置文件applicationContext.xml
<beans>
……
<bean id="EmployeeService"
class="com.dh.service.EmployeeService">
<property name="employeeDao">
<ref local="EmployeeDao" />
</property>
</bean>
<bean id="EmployeeAction" class=" " >
<property name=" " ref=" "/>
</bean>
</beans>
5.struts.xml配置文件
<struts>
<package name="admin" extends="struts-default" >
<action >
<result >employeeList.jsp</result>
</action>
</package>
</struts>
6.在employeeList.jsp页面显示对应的结果
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>员工列表界面</title>
</head>
<body>
<table border="1px">
<tr>
<td>ID</td>
<td>员工姓名</td>
<td>基本工资</td>
<td>出生日期</td>
<td>籍贯</td>
</tr>
<s:iterator var="emp">
<tr>
<td>${emp.id }</td>
<td> </td>
<td>${emp.salary }</td>
</tr>
</s:iterator>
</table>
</body>
</html>
明天给你做,等着吧,采纳先验证一下正确性,不要乱采纳耶
明天发个demo看你,关注一下,私信发给你。
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>新增员工资料</title>
</head>
<body>
<h1 align="center">新增员工资料</h1>
<hr/>
<s:form action="empAction!save.action" method="post">
<s:hidden name="emp.empid"/>
<s:hidden name="acc.empid"/>
<s:textfield name="emp.empname" label="员工姓名"/>
<s:select name="dep.deptid" list="#request.depList" listKey="deptid" listValue="deptname" label="所属部门"></s:select>
<s:radio name="emp.sex" list="#{'男':'男','女':'女'}" listKey="key" listValue="value" value="'男'" label="性别"></s:radio>
<s:textfield name="emp.birthday" label="出生日期"/>
<s:textfield name="emp.school" label="毕业学校"/>
<s:textfield name="emp.major" label="所学专业"/>
<s:textfield name="emp.degree" label="学历"/>
<s:textfield name="emp.mobile" label="手机号码"/>
<s:textfield name="acc.username" label="登录账号"/>
<s:textfield name="acc.passwd" label="登录密码"/>
<s:textfield name="passwd1" label="确认密码"/>
<s:select name="acc.status" list="#{'启用':'启用','禁用':'禁用'}" listKey="key" listValue="value" label="状态"></s:select>
<s:submit value=" 注 册 "> </s:submit>
</s:form>
</body>
</html>
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632