基于SSH框架实现树形结构页面还原以及简单的登录功能

基于SSH协议的安全通信 一、SSH SSH的全称为Security Shell,其目的是要在非安全网络上提供安全的远程登录和其它安全网络服务,通常代替TELNET协议、RSH协议等来使用。SSH允许客户机通过网络连接到远程服务器并运行该服务器上的应用程序,被广泛应用于系统管理中,可对客户机和服务器之间的数据流进行加密。 SSH分为客户端和服务端两个部分。服务端是一个守护进程,在后台运行并响应来自客户端的连接请求;一般 阅读详情

基于SSH框架实现树形结构页面还原以及简单的登录功能(没有注册功能),基于数据库设计表存储结构,该存储结构能够通用,改变树形的内容(如换成公司人员组成树)也可以存储

前言

在前面找工作面试时,一家公司给出的机试题.由于没有用过SSH,只好查找各种资料搭建了一个SSH框架按照要求实现了一非常简单的登录功能,以及题目要求的树形结构的还原.
----由于经验缺乏,技术不足. 有不对的地方还请大家多多指点,谢谢!

一、什么是SSH框架

SSH是 (struts+spring+hibernate) 的一个集成框架,是一种Web应用程序开源框架。

SSH有SSH1和SSH2两种,本文使用的是SSH2。

二、Struts+Spring+Hibernate 各个作用

Strtus: 基于MVC设计模式,可以使我们的逻辑变得清晰
Spring: IOC和AOP可以使我们的程序最大限度上解耦合
Hibernate: 持久层框架,操作数据库

三、开发环境

Eclipse + PowerDesigner + Navicat + MySql + JDK 1.8 + Tomcat 8.5

四、数据库设计

(根据要求使用PowerDesigner简单设计两张表)
1. 用户表:
在这里插入图片描述
在这里插入图片描述
建表语句:

drop table if exists sys_user;

/*==============================================================*/
/* Table: sys_user                                              */
/*==============================================================*/
create table sys_user
(
   user_id              varchar(32) not null comment '用户id',
   user_name            varchar(32) not null comment '用户名',
   user_password        varchar(32) not null comment '登录密码',
   create_time          char(14) comment '创建时间',
   update_time          char(14) comment '更新时间',
   primary key (user_id)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

alter table sys_user comment '用户表';

插入数据:

-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES ('001', 'admin', '123', '20190325000000', '20190325000000');

*用户表密码应当加密存储

2. 树形结构表:
在这里插入图片描述
在这里插入图片描述
建表语句:

drop table if exists tree_list;

/*==============================================================*/
/* Table: tree_list                                             */
/*==============================================================*/
create table tree_list
(
   tree_id              varchar(32) not null comment '树形结构_id',
   tree_name            varchar(32) not null comment '树形结构_名称',
   tree_code            varchar(32) not null comment '树形结构_编号(根据实际业务,比如保存城市信息,这个此段可以存储城市的邮编或者地区号)',
   tree_parent_id       varchar(32) not null comment '树形结构_父类id',
   primary key (tree_id)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

alter table tree_list comment '树形结构表';

插入数据:

-- ----------------------------
-- Records of tree_list
-- ----------------------------
INSERT INTO `tree_list` VALUES ('001', '中国', '0086', '1');
INSERT INTO `tree_list` VALUES ('002', '北京', '100000', '001');
INSERT INTO `tree_list` VALUES ('003', '上海', '200000', '001');
INSERT INTO `tree_list` VALUES ('004', '天津', '300000', '001');
INSERT INTO `tree_list` VALUES ('005', '大兴', '102600', '002');
INSERT INTO `tree_list` VALUES ('006', '房山', '102400', '002');
INSERT INTO `tree_list` VALUES ('007', '黄浦', '200001', '003');
INSERT INTO `tree_list` VALUES ('008', '宝山', '201900', '003');
INSERT INTO `tree_list` VALUES ('009', '武清', '301700', '004');
INSERT INTO `tree_list` VALUES ('010', '塘沽', '300450', '004');

本Demo存储的是城市信息:
1:tree_id 当前节点城市id
2:tree_name 当前节点城市名称
3:tree_code 当前节点城市邮编
4.tree_parent_id 当前节点城市上级地市 id

*该树形结构表,根据实际业务添加更多字段.

五、搭建SSH框架

1.创建一个Web项目,首先打开Eclipse软件,打开后在工具栏依次点击【File】>【New】>【Dynamic Web Project】,这个就代表新建的项目是WEB项目
在这里插入图片描述
2.如果找不到【Dynamic Web Project】这个选项,说明以前没有建立过WEB项目,所以不在快捷导航里,这时点击【Other】这个选项
在这里插入图片描述
3. 这个界面弹出的是查询窗口,查询的内容是所有我们可以建立的项目类型,比如JAVA项目、WEB项目等,都可以再找个窗口查询得到
在这里插入图片描述
4. 填写项目基本信息, 包括(项目名称, tomcat版本等) *名称自定义
在这里插入图片描述
5.Next到此页面时, 勾选: Generate web.xml deployment descriptor 将自动创建web.xml文件

在这里插入图片描述
6.刚创建好的Web工程目录
在这里插入图片描述
7.修改工作空间字符编码 UTF-8
在这里插入图片描述
8.设置JSP编码格式 UTF-8
在这里插入图片描述
9.修改Java代码提示,在下边红色框内输入:.abcdefghijklmnopqrstuvwxyz
在这里插入图片描述
10.控制台->Servers 空白处右键新建一个 Server
在这里插入图片描述
11.如果控制台没有Servers窗口, 选择 Window->Show View->Servers
在这里插入图片描述
如果还没有,就点击下面的 Other… ,里面搜索添加即可

12.选择对应的tomcat版本, 服务名称随意
在这里插入图片描述
13. 选择刚刚新建的Web工程名称,点击add,添加到右侧
在这里插入图片描述
14. 如图,点击 Finish
在这里插入图片描述
15. 此时,服务已经添加完成. 双击新添加的服务,将显示该服务的详细配置信息. http默认端口为:8080
在这里插入图片描述
在这里插入图片描述
16. 在WebContent目录右键,创建一个JSP页面
在这里插入图片描述
17. 命名为 index.jsp , jsp页面输出一段文字,测试服务是否正常启动
在这里插入图片描述
18.选择刚刚新建的Tomcat服务, 右键选择 Start启动服务
在这里插入图片描述
18. 显示一下信息表示服务启动成功, HTTP端口为:8080
在这里插入图片描述
19. 打开浏览器, 地址栏输入: http://localhost:8080/guanglian/ , 正常则会显示刚刚创建的页
在这里插入图片描述
–以上步骤 Web工程以及Tomcat服务已经成功创建–
–以下步骤是SSH框架搭建以及简单的用户登录功能–
20.添加工程所用的jar包到: WebContent->WEB-INF->lib 目录下
在这里插入图片描述
在这里插入图片描述
21. 配置Web.xml文件
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>guanglian</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  <!-- 让spring随web启动而创建的监听器 -->
  <listener>
  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!-- 配置spring配置文件位置参数 -->
  <context-param>
  	<param-name>contextConfigLocation</param-name>
  	<param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  
  <!-- 扩大session作用范围 -->
   <filter>
  	<filter-name>openSessionInView</filter-name>
  	<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
  </filter>
  
  <!-- struts2核心过滤器 -->
  <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  
  <filter-mapping>
  	<filter-name>struts2</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping>
  
</web-app>

22.配置applicationContext.xml文件
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns="http://www.springframework.org/schema/beans" 
		xmlns:context="http://www.springframework.org/schema/context"
		xmlns:aop="http://www.springframework.org/schema/aop" 
		xmlns:tx="http://www.springframework.org/schema/tx"
		xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
							http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd 
							http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
							http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
	
	<!-- 读取db.properties文件 -->
	<context:property-placeholder location="classpath:db.properties" />
	
	<!-- 配置c3p0连接池 -->
	<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
		<property name="jdbcUrl" value="${jdbc.jdbcUrl}" ></property>
		<property name="driverClass" value="${jdbc.driverClass}" ></property>
		<property name="user" value="${jdbc.user}" ></property>
		<property name="password" value="${jdbc.password}" ></property>
	</bean>
	
	<!-- 核心事务管理器 -->
	<bean name="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager" >
		<property name="sessionFactory" ref="sessionFactory" ></property>
	</bean>

	<!-- 开启注解事务 -->
	<tx:annotation-driven transaction-manager="transactionManager" />
	
	<!-- 在spring配置中放置hibernate配置信息 -->
	<bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" >
	
		<!-- 将连接池注入到sessionFactory, hibernate会通过连接池获得连接 -->
		<property name="dataSource" ref="dataSource" ></property>
		
		<!-- 配置hibernate基本信息 -->
		<property name="hibernateProperties">
			<props>
				<!-- 方言 -->
				<prop key="hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>
				
				<!-- 可选配置 -->
				<prop key="hibernate.show_sql" >true</prop>
				<prop key="hibernate.format_sql" >true</prop>
				<prop key="hibernate.hbm2ddl.auto" >update</prop>
			</props>
		</property>
		<!-- 指定domian数据所在的包路径,spring会自动读取包中的所有配置 -->
		<property name="mappingDirectoryLocations" value="classpath:com/demo/domain" ></property>
		
	</bean>
	
</beans>

23.添加 配置文件: db.properties , applicationContext.xml需要引用的数据库连接配置文件
在这里插入图片描述

jdbc.jdbcUrl=jdbc:mysql://IP地址:端口/数据库?autoReconnect=true&amp;autoReconnectForPools=true&amp;useUnicode=true&amp;characterEncoding=UTF-8
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.user=用户名
jdbc.password=密码

24.配置struts.xml文件
在这里插入图片描述

<?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>
	
	<!-- 将action的创建交给spring容器 -->
	<constant name="struts.objectFactory" value="spring"></constant>
	
	<package name="guanglian" namespace="/" extends="struts-default" >
	
		<interceptors>
			<!-- 注册拦截器 -->
			<interceptor name="loginInterceptor" class="com.demo.web.interceptor.loginInterceptor"></interceptor>
			
			<!-- 配置拦截器栈 -->
			<interceptor-stack name="myStack">
				<interceptor-ref name="loginInterceptor">
					<!-- 放行的方法 -->
					<param name="excludeMethods">login</param>
				</interceptor-ref>
				<interceptor-ref name="defaultStack"></interceptor-ref>
			</interceptor-stack>
		</interceptors>
		<!-- 指定默认拦截器栈 -->
		<default-interceptor-ref name="myStack"></default-interceptor-ref>
		
		<!-- 全局结果集配置 -->
		<global-results>
			<result name="toLogin" type="redirect" >/login.jsp</result>
		</global-results>
	
		<!-- 异常处理的配置 -->
		<global-exception-mappings>
			<exception-mapping result="error" exception="java.lang.RuntimeException"></exception-mapping>
		</global-exception-mappings>
	</package>
	
</struts>

25.分层创建包路径,并且创建数据表对应的实体类
在这里插入图片描述

实体类: City.java

package com.demo.domain;

/**
 * @Description 城市信息实体类
 * @author TianHB
 */
public class City {

	private String tree_id; //树形结构_id
    private String tree_name; //树形结构_名称
    private String tree_code; //树形结构_编号
    private String tree_parent_id; //树形结构_父类id
   
	public String getTree_id() {
		return tree_id;
	}
	public void setTree_id(String tree_id) {
		this.tree_id = tree_id;
	}
	public String getTree_name() {
		return tree_name;
	}
	public void setTree_name(String tree_name) {
		this.tree_name = tree_name;
	}
	public String getTree_code() {
		return tree_code;
	}
	public void setTree_code(String tree_code) {
		this.tree_code = tree_code;
	}
	public String getTree_parent_id() {
		return tree_parent_id;
	}
	public void setTree_parent_id(String tree_parent_id) {
		this.tree_parent_id = tree_parent_id;
	}
}

实体类: User.java

package com.demo.domain;

/**
 * @Description 用户信息实体类
 * @author TianHB
 */
public class User {

	private String user_id; //用户id
	private String user_name; //用户名
	private String user_password; //用户登录密码
	private String create_time; //该用户创建时间
	private String update_time; //该用户信息更新时间(例如修改密码)
	
	public String getUser_id() {
		return user_id;
	}
	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}
	public String getUser_name() {
		return user_name;
	}
	public void setUser_name(String user_name) {
		this.user_name = user_name;
	}
	public String getUser_password() {
		return user_password;
	}
	public void setUser_password(String user_password) {
		this.user_password = user_password;
	}
	public String getCreate_time() {
		return create_time;
	}
	public void setCreate_time(String create_time) {
		this.create_time = create_time;
	}
	public String getUpdate_time() {
		return update_time;
	}
	public void setUpdate_time(String update_time) {
		this.update_time = update_time;
	}
}

26.创建实体类对应的Hibernate映射文件,在domain包下
在这里插入图片描述
User.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.demo.domain" >
	<!-- User 用户实体类对象映射文件 -->
	<class name="User" table="sys_user" >
		<id name="user_id">  
           <column name="user_id"/>  
        </id>  
		<property name="user_name"  ></property>
		<property name="user_password"  ></property>
		<property name="create_time"  ></property>
		<property name="update_time"  ></property>
	
	</class>
</hibernate-mapping>

City.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.demo.domain" >
	<!-- City 城市信息实体类对象映射文件 -->
	<class name="City" table="tree_list" >
		<!-- 主键id -->
		<id name="tree_id">  
           <column name="tree_id"/>  
        </id>  
		<property name="tree_name"  ></property>
		<property name="tree_code"  ></property>
		<property name="tree_parent_id"  ></property>
	</class>
</hibernate-mapping>

27.在WebContent目录下创建一个登陆页面: login.jsp
在这里插入图片描述

<%@ 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 action="${pageContext.request.contextPath}/UserAction_login" method="post">
	
		用户名:<input type="text" name="user_name">
		
	 	   密码:<input type="password" name="user_password">
		
			   <input type="submit" value="登录">
			   
			   <!-- 错误提示 -->
			   <font color="red" ><s:property value="exception.message" /> </font>
	</form>
	
	<s:debug></s:debug>
	
</body>
	
</html>

28.创建登录的 UserAction.java , login.jsp登录请求的: UserAction_login 方法
在这里插入图片描述
UserAction.java

package com.demo.web.action;

import com.demo.domain.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @Description 用户Action
 * @author TianHB
 */
public class UserAction extends ActionSupport implements ModelDriven<User>{
	
	//用户接收前端请求页面传来的参数对象
	private User user = new User();

	private UserService userService;

	//注入UserService对象
	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	/**
	 * @Description 用户登录方法
	 * @return
	 */
	public String login() throws Exception {
		
		//1.调用Service执行查询对象方法
		User u = userService.getUserByNamePassword(user);
		
		//2.将返回的user对象放入session域中
		ActionContext.getContext().getSession().put("user", u);
		
		//3.重定向到首页
		return "toHome";
	}

	@Override
	public User getModel() {
		return user;
	}
	
}

29.创建登录的 UserService.java , 并编写获取用户对象方法
在这里插入图片描述

package com.demo.service;

import com.demo.domain.User;

/**
 * @Description 用户Service
 * @author TianHB
 */
public interface UserService {
	
	/**
	 * @Description 获取用户对象
	 * @return
	 */
	User getUserByNamePassword(User user);
	
}

30.创建UserService.java的实现类: UserServiceImpl.java
在这里插入图片描述

package com.demo.service.impl;

import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.demo.dao.UserDao;
import com.demo.domain.User;
import com.demo.service.UserService;

/**
 * @Description 用户Service实现类
 * @author TianHB
 */
@Transactional(isolation=Isolation.REPEATABLE_READ, propagation=Propagation.REQUIRED, readOnly=true)
public class UserServiceImpl implements UserService{

	private UserDao userDao;
	
	//注入UserDao
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
	/**
	 * @Description 调用dao层获,获取User对象
	 * @return
	 */
	@Override
	public User getUserByNamePassword(User user) {
		
		System.out.println(userDao);
		
		//调用Dao层获取用户对象
		User u = userDao.getUserByUserName(user.getUser_name());
		
		//判断用户是否存在,不存在抛出异常:提示用户名不存在
		if(u == null) {
			throw new RuntimeException("用户名不存在");
		}
		
		//判断用户输入的密码和数据库中的密码是否一致,如何不一致抛出异常:用户名或密码错误
		if(!u.getUser_password().equals(user.getUser_password())) {
			throw new RuntimeException("用户名或密码错误");
		}
		
		//返回查询到的用户对象
		return u;
	}
}

31.创建用户登录的Dao层, UserDao.java
在这里插入图片描述

package com.demo.dao;

import com.demo.domain.User;

/**
 * @Description 用户Dao接口
 * @author TianHB
 */
public interface UserDao {
	
	/**
	 * @Description 根据用户名查询用户对象信息
	 * @return
	 */
	User getUserByUserName(String userName);
	
}

32.创建UserDao.java的实现类:UserDaoImpl.java
在这里插入图片描述

package com.demo.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import com.demo.dao.UserDao;
import com.demo.domain.User;

/**
 * @Description 用户Dao实现类
 * @author TianHB
 */
public class UserDaoImpl extends HibernateDaoSupport implements UserDao{

	/**
	 * @Description 根据用户名获取用户对象
	 * @return
	 */
	@Override
	public User getUserByUserName(String userName) {
		
		//创建Criteria查询
		DetachedCriteria criteria = DetachedCriteria.forClass(User.class);
		
		//添加查询条件
		criteria.add(Restrictions.eq("user_name", userName));
		
		//查询返回的对象集合
		List<User> userList = (List<User>) getHibernateTemplate().findByCriteria(criteria);
		
		//如果集合不为null,并且长度大于一说明查询到了用户对象,获取第一个并返回
		if(userList != null && userList.size() > 0) {
			return userList.get(0);
		}else {
			return null;
		}
		
	}

}

33.将用户登录的三层: Action,Service,Dao添加到Spring容器中
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns="http://www.springframework.org/schema/beans" 
		xmlns:context="http://www.springframework.org/schema/context"
		xmlns:aop="http://www.springframework.org/schema/aop" 
		xmlns:tx="http://www.springframework.org/schema/tx"
		xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
							http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd 
							http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
							http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
	
	<!-- 读取db.properties文件 -->
	<context:property-placeholder location="classpath:db.properties" />
	
	<!-- 配置c3p0连接池 -->
	<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
		<property name="jdbcUrl" value="${jdbc.jdbcUrl}" ></property>
		<property name="driverClass" value="${jdbc.driverClass}" ></property>
		<property name="user" value="${jdbc.user}" ></property>
		<property name="password" value="${jdbc.password}" ></property>
	</bean>
	
	<!-- 核心事务管理器 -->
	<bean name="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager" >
		<property name="sessionFactory" ref="sessionFactory" ></property>
	</bean>

	<!-- 开启注解事务 -->
	<tx:annotation-driven transaction-manager="transactionManager" />
	
	<!-- 在spring配置中放置hibernate配置信息 -->
	<bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" >
	
		<!-- 将连接池注入到sessionFactory, hibernate会通过连接池获得连接 -->
		<property name="dataSource" ref="dataSource" ></property>
		
		<!-- 配置hibernate基本信息 -->
		<property name="hibernateProperties">
			<props>
				<!-- 方言 -->
				<prop key="hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>
				
				<!-- 可选配置 -->
				<prop key="hibernate.show_sql" >true</prop>
				<prop key="hibernate.format_sql" >true</prop>
				<prop key="hibernate.hbm2ddl.auto" >update</prop>
			</props>
		</property>
		<!-- 指定domian数据所在的包路径,spring会自动读取包中的所有配置 -->
		<property name="mappingDirectoryLocations" value="classpath:com/demo/domain" ></property>
		
	</bean>

	<!-- UserAction -->
	<bean name="userAction" class="com.demo.web.action.UserAction" scope="prototype">
		<property name="userService" ref="userService"></property>
	</bean>

	<!-- UserService -->
	<bean name="userService" class="com.demo.service.impl.UserServiceImpl">
		<property name="userDao" ref="userDao"></property>
	</bean>
	
	<!-- UserDao -->
	<bean name="userDao" class="com.demo.dao.impl.UserDaoImpl">
		<!-- 注入sessionFactory -->
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	
</beans>

34.在struts.xml文件中配置login请求转发的jsp
在这里插入图片描述
在这里插入图片描述

<?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>
	
	<!-- 将action的创建交给spring容器 -->
	<constant name="struts.objectFactory" value="spring"></constant>
	
	<package name="guanglian" namespace="/" extends="struts-default" >
	
		<interceptors>
			<!-- 注册拦截器 -->
			<interceptor name="loginInterceptor" class="com.demo.web.interceptor.loginInterceptor"></interceptor>
			
			<!-- 配置拦截器栈 -->
			<interceptor-stack name="myStack">
				<interceptor-ref name="loginInterceptor">
					<!-- 放行的方法 -->
					<param name="excludeMethods">login</param>
				</interceptor-ref>
				<interceptor-ref name="defaultStack"></interceptor-ref>
			</interceptor-stack>
		</interceptors>
		<!-- 指定默认拦截器栈 -->
		<default-interceptor-ref name="myStack"></default-interceptor-ref>
		
		<!-- 全局结果集配置 -->
		<global-results>
			<result name="toLogin" type="redirect" >/login.jsp</result>
		</global-results>
	
		<!-- 异常处理的配置 -->
		<global-exception-mappings>
			<exception-mapping result="error" exception="java.lang.RuntimeException"></exception-mapping>
		</global-exception-mappings>
	
			
		<action name="UserAction_*" class="userAction" method="{1}" >
			<result name="toHome">/index.jsp</result>
			<result name="error" >/login.jsp</result>
		</action>
		
	</package>
	
</struts>

登录成功之后将跳转到index.jsp中,如果登录失败将跳转到本页面

35.浏览器地址栏输入: http://localhost:8080/guanglian/login.jsp ,测试功能效果
在这里插入图片描述
36.输入数据库中存储的用户名密码, 账号: admin 密码: 123 , 登录测试
登录成功跳转页面: 跳转到 index.jsp
在这里插入图片描述
密码错误,登录失败还是本页,并提示: 用户名或密码错误
在这里插入图片描述
用户错误,登录失败还是本页,并提示: 用户名不存在
在这里插入图片描述
37.创建拦截器对象,除了login请求不拦截,其余请求全拦截(如果有注册功能,注册请求需放行)
在这里插入图片描述

package com.demo.web.interceptor;

import java.util.Map;

import com.demo.domain.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

/**
 * @Description 配置拦截器对象
 * @author TianHB
 *
 */
public class loginInterceptor  extends MethodFilterInterceptor{

	/**
	 * @Description 不拦截登录Action,其他请求Action都拦截
	 * @return
	 */
	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		
		//1 获得Session
		Map<String, Object> session = ActionContext.getContext().getSession();
		
		//2 获得登陆标识
		User user = (User) session.get("user");
		
		//3 判断标识是否存在
		if(user != null){
			//存在->放行
			return invocation.invoke();
		}else{
			//不存在-> 重定向到登陆页面
			return "toLogin";
		}
	}

}

38.struts.xml中配置该拦截器对象的拦截规则
在这里插入图片描述

<?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>
	
	<!-- 将action的创建交给spring容器 -->
	<constant name="struts.objectFactory" value="spring"></constant>
	
	<package name="guanglian" namespace="/" extends="struts-default" >
	
		<interceptors>
			<!-- 注册拦截器 -->
			<interceptor name="loginInterceptor" class="com.demo.web.interceptor.loginInterceptor"></interceptor>
			
			<!-- 配置拦截器栈 -->
			<interceptor-stack name="myStack">
				<interceptor-ref name="loginInterceptor">
					<!-- 放行的方法 -->
					<param name="excludeMethods">login</param>
				</interceptor-ref>
				<interceptor-ref name="defaultStack"></interceptor-ref>
			</interceptor-stack>
		</interceptors>
		<!-- 指定默认拦截器栈 -->
		<default-interceptor-ref name="myStack"></default-interceptor-ref>
		
		<!-- 全局结果集配置 -->
		<global-results>
			<result name="toLogin" type="redirect" >/login.jsp</result>
		</global-results>
	
		<!-- 异常处理的配置 -->
		<global-exception-mappings>
			<exception-mapping result="error" exception="java.lang.RuntimeException"></exception-mapping>
		</global-exception-mappings>
	
			
		<action name="UserAction_*" class="userAction" method="{1}" >
			<result name="toHome">/index.jsp</result>
			<result name="error" >/login.jsp</result>
		</action>
		
	</package>
	
</struts>

39.测试拦截器是否好用, 在UserAction.java中创建一个 test方法,进行访问测试
在这里插入图片描述
40.访问 http://localhost:8080/guanglian/UserAction_test 测试拦截器
当前用户为未登录状态:
在这里插入图片描述
测试拦截器成功跳转到: http://localhost:8080/guanglian/login.jsp 登录页面
在这里插入图片描述
现在进行登录:
在这里插入图片描述
再次测试访问: http://localhost:8080/guanglian/UserAction_test
查看后台输出语句:
在这里插入图片描述
拦截器测试通过.
–以上步骤是SSH框架搭建以及简单的用户登录功能–
–以下步骤是树形结构的后台代码以及前台页面功能–

树形结构还原功能预览:
在这里插入图片描述
*因时间原因,后续完善树形结构的后台代码以及前台页面功能,抱歉…
*多有不足,有问题的地方还请多多指教,谢谢…

嵌入式全流程实战:从单片机到Linux内核与AI部署 嵌入式开发并非单纯的点灯与串口通信,而是一套从需求拆解到量产安全的系统工程。理解嵌入式流程,首先需要掌握单片机与嵌入式Linux的选型逻辑,明确RTOS与完整操作系统在不同场景下的适用边界。在Linux体系下,交叉编译工具链的配置、内核源码的按需阅读与裁剪,以及设备树的引脚管理,构成了驱动开发和系统稳定的基石。同时,随着边缘计算兴起,轻量化AI模型在嵌入式设备上的转换、量化与NPU调优,正成为新的核心技能。从环境监控到量产安全,从Rust嵌入式的新兴实践到现场问题的排查方法,完整闭环的工程思维远比碎片化知识 阅读详情

相关推荐

影城管理系统毕业设计实战:源码运行、核心逻辑与答辩准备

前后端分离架构已成为Java Web开发的主流范式,Spring Boot提供轻量级服务端能力,Vue负责交互界面,MySQL承载业务数据。在工程实践中,数据库表结构设计与订单状态机是业务系统的关键环节,而并发场景下的防超卖逻辑则考验开发者的系统思维。这类技术组合广泛应用于高校实训、毕业设计和中小型业务系统。基于上述背景,本文以一款经典的影城管理系统为例,围绕毕业设计“源码+数据库+论文”三件套,完整梳理了从源码包校验、环境配置、前后端联调,到核心表结构拆解、订单流程与座位锁定的实现思路,并针对论文撰写和答

weixin_34364071的博客 468

基于SSH框架的管理系统【完整项目源码】

基于SSH框架的管理系统 【文末附源码】 1前言 基于SSH框架的管理系统简洁版; 实现登录、注册、增、删、改、查; 可继续完善增加前端、校验、其他功能等; 可作为SSH(StructsSpringHibernate)项目开发练习基础模型; 课程设计、毕业设计开发基础; 任何复杂的框架都是简单的知识组合并延伸的,学好基础知识才是最重要的; 此项目简单,便于理解基本原理,为复杂SSH复杂项目的开发打下基础。 2环境准备 开发平台:IDEA2019 数据库:MySQL ...

我要学Java_blog 6756

基于ssh框架的购物商城

帮助大家学习javaweb开发,ssh框架使用,支付流程,订单商品的管理。

ssh工作流程及其原理——ssh免密登录

ssh工作流程及其原理、对称加密、非对称加密、ssh免密登录

阿瑾的博客 1649

告别环境报错:Qt Creator里配置Android SDK/NDK/JDK路径的完整避坑指南

本文详细解析了在Qt Creator中配置Android SDK/NDK/JDK路径的完整避坑指南,深入探讨了路径检测的内部机制、构建套件配置的隐藏逻辑以及项目级与全局配置的优先级。通过实际案例和高级排查技巧,帮助开发者解决常见的环境报错问题,提升Qt安卓开发效率。

weixin_42548829的博客 238

高分系列卫星轨道、传感器参数等信息

遥感卫星数据简介-高分系列

中遥科 3310

【linux】linux设置ssh密钥登录详细教程,附Mobaxterm和pycharm ssh python解释器配置教程

我们通常使用SSH 客户端来远程使用 Linux 服务器。但是,一般的密码方式登录,容易有密码被暴力破解的问题。所以,一般我们会将 SSH 的端口设置为默认的 22 以外的端口,或者禁用 root 账户登录。但是即使是将端口设置为22之外的端口也容易泄露。为了保证服务器安全,此时希望使用密钥方式登录。而且使用秘钥登录能够避免每次登录时反复输入账户密码。

weixin_43693967的博客 2万+

实战STM32G0驱动DRV8870/AT8870:PWM+DMA精准调速与H桥衰减模式详解

本文详细介绍了如何使用STM32G0单片机结合DRV8870/AT8870电机驱动芯片实现直流有刷电机的精准控制。重点讲解了PWM与DMA结合实现高效调速的硬件配置与软件驱动方法,并深入剖析了H桥快衰减与慢衰减模式的工作原理及应用场景,为嵌入式电机控制项目提供了完整的实战解决方案。

c7d8e9的博客 595

实现远程登录-配置SSH

②客户端向服务器端发起 TCP 初始连接请求,TCP 连接建立后,服务器向客户端发送第一个报文包括版本标志字符串,格式为“SSH-主协议版本号 >< 次协议版本号 >-< 软件版本号 ”,协议版本号由主版本号和次版本号组成,软件版本号主要是为调试使用。③客户端收到报文后,解析该数据包,如果服务器端的协议版本号比自己的低且客户端能支持服务器端的低版本,就使用服务器端的低版本协议号,否则使用自己的协议版本号。②服务器端对客户端进行认证,如果认证失败,则向客户端发送认证失败消息,其中包含可以再次认证的方法列表。

weixin_63037066的博客 5636

Cadence17.2 > OrCAD Capture CIS > 设计规则检查(Design Rule Check)DRC学习记录详解

选中设计完成的DSN文件,选择Tool->Design Rule Check,弹出下面对话框,详解如下。 一、Design Rule Check对话框选项详解 Design Rules Options tab Set the scope, mode and type of design rule (electrical and / or physical) test options for the design rules check. 为

DL_62532的专栏 1万+

cherry使用MCP协议Streamable HTTP实践

摘要:Streamable HTTP协议是针对传统HTTP+SSE传输方式的改进方案,解决了连接恢复、服务器资源占用和单向通信等问题。该协议基于普通HTTP实现,支持无状态服务器、纯HTTP服务和多轮对话,同时兼容现有基础设施。通过演示展示了服务端和客户端的配置方法,体现了其灵活性和实用性。MCP(多轮对话协议)作为扩展LLM能力的关键技术,代表着未来交互式AI的发展趋势。

全网120W+关注AI拉呱,专注人工智能以及科技前沿! 563

快速入门五 SSH2附带源码

博客地址  http://blog.youkuaiyun.com/ftx2540993425 1.1 后台管理: 1.1.1 后台页面的布局: 采用框架进行布局: * 使用dtree.js作为树形结构菜单:   1.1.2 后台登录功能: 1.引入后台管理页面: 2.创建表: CREATE TABLE `adminuser` (   `uid` int(11) NOT 

菜鸟的飞翔 997

手把手教你RK3568 MIPI屏驱动适配,纯干货!

RK3568 作为一款高性能的多媒体处理器,在嵌入式领域中备受瞩目。它采用了先进的 22nm 制程工艺,搭载四核 Cortex-A55 处理器,这种架构为芯片提供了高效的功耗比,使其在运行各种复杂任务时,既能保证性能,又能有效控制功耗。在实际应用中,无论是多任务处理还是运行大型应用程序,RK3568 都能凭借其四核 Cortex-A55 处理器,实现流畅的操作体验,满足智能设备对高性能和低功耗的需求。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 4071

SSH网上商城--后台登录

本篇通过简单的后台登录来讲解SSH的应用,页面主要采用框架来进行布局,通过dtree.js作为树形结构菜单来使用。 主要登录功能的实现有以下步骤组成 1.后台管理页面。由于资料里已给出,可直接在WebRoot下新建admin文件夹后将后台页面直接引入即可,这里不做详细说明,页面也可自行制作。(注意css和image等的引用是否存在)。启动服务器后,打开浏览页面,如下图所示

杜 2105

[RAM] DRAM 导论:DDR4 | DDR5 | LPDDR5 | GDRR6 | HBM 应运而生

有数据的地方就有存储, 内存是谁都离不开的产品。而动态随机存取存储器(DRAM)作为一种常见的内存。本博客将介绍DRAM的基本概念、工作原理、优缺点以及应用领域等方面。

串起点滴 3920

《大数据最全面试题-Offer直通车》目录

做好这些不用担心试用期不通过:程序员入职新公司如何快速上手项目本人遇到大数据面试题和参考答案(超过1万字精华版)大数据面试英文自我介绍参考(万字长文)大数据运维应用场景面试题汇总及参考答案(持续更新)万字数据仓库面试题及参考答案数据仓库数据质量监控和处理方法最佳实践数据仓库建模方法万字详解Doris的3种数据模型详解和数据仓库每一层的模型选用大数据面试临阵磨枪不知看什么?看这份心理就有底了-大数据常用技术栈常见面试100道题最全Hive面试题2024年(2万字详解)Elasticsearch 面试题及参考答

大模型大数据攻城狮的专栏 2648

基于MVC设计模式实战ExtJS4.2高级组件+SSH2在线投稿系统

百度网盘下载:http://pan.baidu.com/s/1i4xQu5B 密码:19r7 00.前言 01.教程简介_ExtJS4.2简介_SSH2基本框架搭建 02.编写几个通用的service方法、设计数据库 03.搭建ExtJS的MVC框架 04.主界面的搭建、登录功能和菜单树的生成 05.创建菜单树、前台保存用户信息 06.菜单树响应事件、我的文章模块界面搭建 07...

iteye_4363的博客 239

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

ssh maven mysql_基于SSH+Maven+Extjs4+MySQL技术实战开发CRM客户关系管理系统

分享一套名为《基于SSH+Maven+Extjs4+MySQL技术实战开发CRM客户关系管理系统》视频教程,讲师是飞扬老师。课程主要内容是extjs4.2高级组件和MVC设计模式,通过一个简单的开发带领大家熟悉常用的高级组件以及extjs4.x的MVC设计模式的使用方式。后台开发使用的技术有:Maven3.1、struts2+spring3+hibernate4框架。课程偏重于extjs4.2框架...

weixin_32867521的博客 227

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

基于SSH+Maven+Extjs4+MySQL技术实战开发CRM客户关系管理系统

这里有套课程和大家分享,有兴趣的朋友可以加我的qq2059055336和我联系、 一、课程简介 1.1、课程背景J2ee技术已经流行很多年了,在很多的B/S架构中之前都是jsp页面组成的。后来产生了很多的前台框架,或者称之为富客户端。Extjs就是其中之一,从起初的版本到extjs4.2版,extjs已经发展为一个成熟的框架了。在企业开发中被广泛的应用。Maven是基于项目对象模型...

各研发管理 187

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

基于SpringBoot+Vue的毕业设计:人事管理系统从零落地实践

SpringBoot作为主流Java后端框架,凭借“约定优于配置”大幅简化了企业级应用的环境搭建与开发流程;Vue则通过组件化与数据驱动实现高效的前后端分离,二者结合MySQL构成中小型管理系统最稳的技术组合。本文面向人事管理系统的完整交付场景,从技术选型逻辑、RBAC权限模型、核心业务模块的表结构设计,到JWT认证、接口分层实现、Vue前端联调,再到Nginx生产部署与答辩材料组织,系统梳理了一套可落地的工程实践路径。无论毕业设计还是内部管理项目,都能从中获得清晰的框架思维与实战避坑经验。

weixin_33417488的博客 302

SpringBoot+Vue+MyBatis+MySQL企业级毕业设计系统全栈实战解析

在前后端分离架构逐渐成为主流开发范式的今天,从零构建一套业务完整、权限清晰的管理系统,是许多开发者迈入工程实践的重要一步。SpringBoot凭借约定大于配置的理念大幅简化服务端搭建,Vue以渐进式组件化高效支撑后台界面,MyBatis则通过可控SQL为复杂查询提供灵活方案,加上MySQL的稳定存储,这套组合已成为中小型商用项目的经典标配。从用户、角色、菜单的RBAC权限模型设计,到JWT登录认证链路;从分层目录组织到服务端接口安全,再到前后端联调时跨域、时区、缓存等高频问题的排查思路,系统化的实现路径能够

weixin_34009794的博客 260

工作中使用到的单词(软件开发)_第五版

本文摘要: 本文为软件开发相关的术语与技术要点整理,主要包含2020-2025年间四版内容更新(No.01-41)。重点包括: 证书文件格式(PEM/P12)差异 外部API通信注意事项(Accept头设置、HTTPS连接问题) Postman工具使用技巧(Cookie管理、请求头设置) WAS配置相关经验(JVM设置、SSL连接问题) 数据库操作命令(DB2表结构修改) IBM安全管理组件(TAM/iv-user机制) 网络通信细节(chunked传输编码特性) 常用开发工具(curl、Postman)的

sun0322 2521

【struts2+hibernate+spring项目实战】实现用户登录功能(ssh)

一、概述 从今天才开始有时间来总结总结以前自己练习的一些东西,希望总结出来对以后可以更加便捷的来学习,也希望可以帮助到正需要这些东西的同行人,一起学习,共同进步。 二、 登录功能总结 2.1、登录功能概述 这个技术主要是运用Struts2+hibernate+spring的技术来进行登录功能的实现的,并且是在一个具体的项目中来实现的,对于以后的借鉴能够提供便捷。 2.2、具体

好好学java 3801

基于SSH框架实现登录功能

基于SSH框架实现登录功能

weixin_61544920的博客 1307

大数据标准化:数据治理的核心技术与实践

数据标准化是数据治理的基础环节,通过建立统一的数据定义和规范,解决多源异构数据的兼容性问题。其核心原理包括极值法、Z-score标准化等方法,确保不同来源的数据能够被统一处理和分析。在金融风控、电商评论分析等场景中,标准化技术显著提升了数据质量和分析效率。随着大数据和AI技术的发展,标准化过程本身也成为了数据质量检测的新维度。本文结合金融、医疗等行业案例,详解结构化与非结构化数据的标准化方法,并分享分布式处理、增量标准化等工程实践。

weixin_33690963的博客 515

SSH远程登录与控制

每次使用sshd登录到其他主机,双方都会生成一个文件known_hosts把对方主机的公钥在.ssh/known_hosts文件里。⑦最终:双方各持有三个密钥,分别为自己的一对公钥、私钥、以及对方的公钥,之后的所有的通讯都会被加密。⑥服务端用解密后的Res或者是会话ID,计算出客户端的公钥(这一步服务端得到客户端公钥)④客户端用自己的公钥或会话ID,计算出一个值Res,并用服务端的公钥加密。②服务端返回自己的公钥,以及一个会话ID(这一步客户端得到服务端公钥)服务端主程序:/usr/sbin/sshd。

MCB134的博客 3万+
下一篇: SpringBoot项目 + Maven + 企业微信登陆授权登陆
iTianhb
博客等级 码龄8年 413粉丝 2原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值