81,094
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
</head>
<body>
<form id="login" action="infoLogin" method="post" namespace="/">
<h1>登录</h1>
<fieldset id="inputs">
<input name="info.dl_name" type="text" required="required"
placeholder="Username" tabindex="1" autofocus>
<input name="info.dl_pass" type="password" required="required"
placeholder="Password" tabindex="2">
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="Log In">
<a href="./update.jsp">Forgot your password?</a>
<a href="./1_login.jsp">Register</a>
</fieldset>
</form>
</body>
</html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="false" />
<constant name="struts.objectFactory" value="spring"></constant>
<package name="default" namespace="/" extends="struts-default">
<!-- class属性值是spring定义的Bean,当执行execute()返回success时,控制转到另一个动作memberQuery -->
<action name="infoRegister" class="infoRegisterAction">
<result name="success" type="redirectAction">infoQuery</result>
</action>
<action name="infoLogin" class="infoLoginAction">
<result name="weihu" type="redirectAction">
<param name="actionName">infoQuery</param>
<!--<param name="info">${info}</param> -->
</result>
<result name="zhiban">register.jsp</result>
<result name="ywsp">register.jsp</result>
<result name="kfsp">register.jsp</result>
<result name="err">register.jsp</result>
</action>
<action name="infoQuery" class="infoQueryAction">
<result name="success">shenqing.jsp</result>
</action>
<action name="infoDelete" class="infoDeleteAction">
<result name="success" type="redirectAction">infoQuery</result>
</action>
<action name="infoShow" class="infoUpdateAction" method="showInfo">
<result name="success">update.jsp</result>
</action>
<action name="infoUpdate" class="infoUpdateAction">
<result name="success" type="redirectAction">infoQuery</result>
</action>
</package>
</struts>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- spring 框架提供了多种数据源类,可以使用spring提供的DriverManagerDataSource类还可以使用第三方数据源,
如C3P0的ComboPooledDataSource数据源类,注意相应的两个jar包c3p0-0.9.2.1.jar mchange-commons-java-0.2.3.4.jar -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)(SERVER=DEDICATED)))" />
<property name="username" value="admin" />
<property name="password" value="admin" />
<!-- <property name="maxPoolSize" value="40" />
<property name="minPoolSize" value="1" />
<property name="initialPoolSize" value="2" />
<property name="maxIdleTime" value="20" /> -->
</bean>
<!-- Hibernate4已经完全实现自己的事物管理,所以spring4不提供HibernateDaoSupport和HibernateTemplete的支持
可以在应用程序的spring上下文中,像配置其他bean那样来配置HibernateSession工厂。 如果要使用XML文件定义对象与数据库之间的映射,则需要在spring中配置LocalSessionFactoryBean。
hibernateProperties属性配置了Hibernate如何进行操作的细节。 "hibernate.current_session_context_class"是为当前Session提供一个策略,
Session由org.springframework.orm.hibernate4.SpringSessionContext.currentSession得到。
将sessionFactory注入到其他Bean中,如注入到DAO组件中,使其获得SessionFactory的引用后,就可以实现对数据库的访问。 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/entity/Info.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
<prop key="hibernate.current_session_context_class">
org.springframework.orm.hibernate4.SpringSessionContext
</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
<bean id="infoDao" class="com.dao.InfoDAOImpl">
<!-- 构造方法注入会话工厂组件sessionFactory -->
<constructor-arg>
<ref bean="sessionFactory" />
</constructor-arg>
</bean>
<bean id="infoService" class="com.service.InfoServiceImpl">
<!-- 设值注入DAO组件 -->
<property name="infoDao" ref="infoDao"></property>
</bean>
<bean id="infoRegisterAction" class="com.action.InfoRegisterAction">
<!-- 设值注入业务逻辑组件 -->
<property name="infoService" ref="infoService"></property>
</bean>
<bean id="infoLoginAction" class="com.action.InfoLoginAction">
<property name="infoService" ref="infoService"></property>
</bean>
<bean id="infoQueryAction" class="com.action.InfoQueryAction">
<property name="infoService" ref="infoService"></property>
</bean>
<bean id="infoDeleteAction" class="com.action.InfoDeleteAction">
<property name="infoService" ref="infoService"></property>
</bean>
<bean id="infoUpdateAction" class="com.action.InfoUpdateAction">
<property name="infoService" ref="infoService"></property>
</bean>
</beans>
package com.action;
import com.entity.Info;
import com.opensymphony.xwork2.ActionSupport;
import com.service.InfoService;
public class InfoLoginAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private Info info;
private InfoService infoService;
public Info getInfo() {
return info;
}
public void setInfo(Info info) {
this.info = info;
}
// 注入业务逻辑组件
public void setInfoService(InfoService infoService) {
this.infoService = infoService;
}
public String execute() {
Info mb = infoService.findByName(info.getDl_name(), info.getDl_pass());
if (mb != null && mb.getLeibie().equals("维护人员"))
return "weihu";
else if (mb != null && mb.getLeibie().equals("值班人员"))
return "zhiban";
else if (mb != null && mb.getLeibie().equals("运维审批"))
return "ywsp";
else if (mb != null && mb.getLeibie().equals("开发审批"))
return "kfsp";
else
return "err";
}
}
package com.action;
import java.util.List;
import org.apache.struts2.ServletActionContext;
import com.entity.Info;
import com.opensymphony.xwork2.ActionSupport;
import com.service.InfoService;
public class InfoQueryAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private InfoService infoService;
private Info info;
public Info getInfo() {
return info;
}
public void setInfo(Info info) {
this.info = info;
}
public void setInfoService(InfoService infoService) {
this.infoService = infoService;
}
public String execute() {
List<Info> list = infoService.findOne("luchang");
ServletActionContext.getRequest().setAttribute("infoList", list);
return SUCCESS;
}
}
<form action="">
<table width="1000px" cellspacing="0" align="center">
<thead>
<tr>
<td colspan="4"><caption>生产操作间进出申请单</caption></td>
</tr>
<!-- <tr>
<td colspan="3" width="85%" style="text-align: right;"><sub>编号:</sub></td>
<td width="15%"><input type="text" name="bianhao"
value="" disabled="disabled" size=35 /></td>
</tr> -->
</thead>
</table>
<table width="1000px" border="3" cellspacing="0" cellpadding="0"
align="center">
<tbody>
<tr>
<td height="30" colspan="4" style="background-color: #AAA;">以下为系统自动填充,无需填写,可根据实际需要调整进入和离开的时间</td>
</tr>
<s:iterator value="#request.infoList" id="info">
<tr>
<td width="200px" height="25">申请单编号</td>
<td width="300px"><input type="text" name="id"
value="<%=number%>" disabled="disabled" size=38 /></td>
<td width="200px">申请日期</td>
<td width="300px"><input type="text" name="renyan"
value="<%=dateT%>" disabled="disabled" size=38 /></td>
</tr>
<tr>
<td height="25">人员姓名</td>
<td><!-- <input type="text" name="riqi" value="#info.xingming"
disabled="disabled" size=38 /> -->
<s:property value="#info.xingming" /></td>
<td>联系方式</td>
<td><input type="text" name="renyan" value=""
disabled="disabled" size=38 /></td>
</tr>