java web大题1

题干

利用三大框架整合技术,向Student表的插入一条数据,具体要求完成如下操作
1.配置Spring MVC核心配置文件springmvc-config.xml,重点配置注解扫描包和视图解析器
2.参照下图Student表结构,完成数据层的Mapper接口及映射文件的编写
3.编写业务层的StudentService接口及其实现类
4.参照下图前台界面,编写信息录入页面login.jsp,并编写Controller接收请求数据,并进行处理。
5.若插入成功,将插入的信息在success.jsp页面中进行显示。
在这里插入图片描述

头文件:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    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/tx 
    http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-4.3.xsd
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-4.3.xsd"> 

代码

1、配置Spring MVC核心配置文件springmvc-config.xml

<!-- 头文件 -->
<?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"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        ">
	<!-- 只扫描controller包 -->
	<context:component-scan base-package="com.haust.controller"></context:component-scan>
	<!-- 自定义视图解析器 -->
	<bean id="viemResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/"></property>
		<property name="suffix" value=".jsp"></property>
	</bean>
</beans>

2、数据层的Mapper接口及映射文件

//StudentMapper接口
public interface StudentMapper {
		public Student insertStudent(Student student);
}

<!-- StudentMapper.xml文件 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.haust.mapper.StudentMapper" >
	<insert id="insertStudent" parameterType="com.haust.Student">
	 	insert into student 
		values(#{student_id},#{sname},#{password},#{sex},#{note})
	 </insert>
</mapper>

3、业务层的StudentService接口及其实现类

//StudentService接口
public interface StudentService {
	public Student insertByStudent(Student student);
}
//实现类
package com.haust.service.impl;
import javax.annotation.Resource;
import com.haust.mapper.StudentMapper;
import com.haust.pojo.Student;
import com.haust.service.StudentService;
public class StudentServiceImpl implements StudentService{
	@Resource
	private StudentMapper  studentMapper;
	public Student insertByStudent(Student student){
		return studentMapper.insertStudent(student);
	}
}

4、login.jsp,并编写Controller接收请求数据,并进行处理

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
	<!-- 只用记这部分 -->
	<form action="${pageContext.request.contextPath}/doLogin" method="post">
	编号:<input type="text" name="student_id"></br>
	姓名:<input type="text" name="sname"></br>
	密码:<input type="text" name="password"></br>
	备注:<textarea rows="3" cols="" name="note"  ></textarea></br>
	性别:<input type="radio" name="sex" value="1"><input type="radio" name="sex" value="0"></br>
	<input type="submit" value="提交">
	<input type="reset" value="重置">	
</form>
</body>
</html>
//StudentController类接收请求数据

@Controller
public class StudentController {
	@Autowired
	StudentService studentService;
	
	@RequestMapping("/login")
	public String tologin(){
		return "login";
	}
	
	@RequestMapping("/doLogin")
	public String insert(Student student, Model model) {
		studentService.insert(student);
		model.addAttribute("student", student);
		return "success";
	}
}

5、success.jsp页面

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
${student.student_id}
${student.sname}

</body>
</html>
  • 9
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
1. 总体介绍 本次项目主要以本学期所学内容为基础,采用servlet+jsp+jdbc的技术以及mvc模式进行项目开发,本次开发的内容主要以实现CRUD核心功能为主的教务管理系统,分为学生端和教师端,前端采用jquery进行数据传输以及处理,bootstap写界面。 2. 技术架构 运行环境:tomcat9+mysql5+maven3.8+jdk8 前端技术:jquery 用以数据处理以及前端验证以及生成验证码等等 Bootstrap 前端界面处理 后端技术:servelt+jsp maven进行jar包和第三方库管理 采用jspsmart进行文件的操作处理 数据库:mysql5 基于MVC的分层思想及采用jsp+servelt技术的B/S结构的应用系统,系统主要开发语言JAVA,JSP。数据库要求使用MySQL8.0,应用服务器选用Tomcat服务器 3. 功能介绍 系统能够提供用户有好的界面 系统具有良好的允许效率 系统具有良好的扩充性,灵活性 系统管理操作简单易懂 3.1 总体结构 3.2 模块详情 学生模块: 注册: 1. 用户点击注册,进行注册; 2. 用户输入注册信息; 3. 校验数据:如果用户名重复或者两次密码校验不合格或者密码规格不符合,则提示错误信息; 4. 若信息无错误,提示注册成功,跳转到登录页。 登录: 1. 用户进入系统未进行登录则自行跳转登录页面; 2. 点击忘记密码可进行密码找回; 3. 提交信息进行校验,查看用户名密码是否为空以及是否符合格式,随后在后台进行校验,合格则进行登录跳转到用户界面; 4. 若登录信息不正确,则提示登录错误信息。 查看成绩: 1. 点击查看成绩,打印成绩列表; 2. 支持到处成绩单为pdf格式。 导出成绩: 1. 点击到处按钮; 2. 系统自动处理并到处成pdf。 个人信息管理: 1. 选择上传头像 2. 修改个人信息:按需填写个人信息,随后进行存则覆盖修改以往的个人信息。 退出登录: 1. 点击退出登录,自动退出到首页并删除本地和服务器缓存。 教师模块: 注册: 1用户点击注册,进行注册; 2用户输入注册信息; 3校验数据:如果用户名重复或者两次密码校验不合格或者密码规格不符合,则提示错误信息; 4若信息无错误,提示注册成功,跳转到登录页。 登录: 1用户进入系统未进行登录则自行跳转登录页面; 2点击忘记密码可进行密码找回; 3提交信息进行校验,查看用户名密码是否为空以及是否符合格式,随后在后台进行校验,合格则进行登录跳转到用户界面; 4若登录信息不正确,则提示登录错误信息。 个人信息管理: 1选择上传头像 2修改个人信息:按需填写个人信息,随后进行存则覆盖修改以往的个人信息。 学生管理: 1. 点击添加学生,填写学生信息进行添加; 2. 修改学生信息,点击修改,按需填写要修改的学生信息,进行存覆盖修改; 3. 点击删除学生数据,提示是否删除,确定则删除,取消则不删除; 4. 查看成绩,点击查看学生成绩,单独列出学生成绩列表; 成绩管理: 1. 点击成绩管理,列出所有学生成绩; 2. 点击修改,勾选需要修改的学生,按需填写修改信息,存覆盖修改学生信息。 退出登录: 1点击退出登录,自动退出到首页并删除本地和服务器缓存。 4. 页面设计 静态jsp页面和jquery和bootstrap 5. 数据库设计 权限对照表: 表名: role 名称 型 长度 允许空值 是否主键 注释 uid 整型 11 否 是 权限等级 utype 字符 255 否 否 用户等级名称 分数表: 表名: score 名称 型 长度 允许空值 是否主键 注释 id 整型 200 否 是 学号 dat 字符 255 否 否 课程1分数 Android 字符 255 否 否 课程2分数 Jsp 字符 255 是 否 课程3分数 学生表: 表名: student 名称 型 长度 允许空值 是否主键 注释 id 整型 59 否 是 学号 password 字符 255 否 否 登陆密码 Name 字符 255 否 否 学生姓名 Sex 字符 255 是 否 性别 School_date 字符 255 是 否 入学时间 Major 字符 255 是 否 专业 email 字符 255 是 否 邮箱 教师表: 表名: student 名称 型 长度 允许空值 是否主键 注释 id 整型 59 否 是 教师工号 password 字符 255 否 否 登陆密码 Name 字符 255 否 否 教师姓名 Sex 字符 255 是 否 性别 email 字符 255 是 否 邮箱
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寂静花开

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值