关于ssm的增删查改在idea和网页上进行操作

对学生信息和班级信息实现增删查改的需求,并在网页上进行:
1.首先在idea上创建一个新的项目(Maven Archetype)Name取为数据库相对应名字,GroupId取为nj.zb.kb22
进行创建,创建结束打开右上角的Edit Configurations ,选中里面的Tomcat Server导入我们下载的Tomcat7.0.78,
在Deployment中我们选择examssm:war的选项进行应用加以使用;
2.在pom.xml中我们配置相关的version和一些需要的包进行下载并且使用;
3.在web.xml中进行配置相关的代码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name></display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext.xml</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>DispatcherServlet</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <filter>
        <filter-name>CharacterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

4.在resources中创建database.properties文件
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://192.168.153.149:3306/exam  //3306/后面的是访问的数据库文件名
user=root
password=root

5.在resources中创建applicationContext.xml文件,相关代码(分为以下八个步骤):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!--1.基础扫描器-->
    <context:component-scan base-package="nj.zb.kb22"></context:component-scan>
    <!--2.指定读取配置文件信息-->
    <context:property-placeholder location="classpath:database.properties"></context:property-placeholder>
    <!--3.配置数据源资源-->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
        <property name="driverClass" value="${driver}"></property>
     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ssm是指Spring+SpringMVC+MyBatis的开发框架组合,通过结合这几个框架可以快速开发Java Web项目。要实现登录、增删改查功能的demo下载,我们需要按照以下步骤进行: 1. 首先,我们需要建立一个基本的SSM项目。可以通过Spring官网下载Spring源码,并且在Maven项目中引入对应的依赖。 2. 在SpringMVC配置文件中配置登录页面和处理登录请求的Controller。我们可以定义一个LoginController类,其中包括一个登录页面和处理用户登录的方法。 3. 在MyBatis配置文件中配置数据库连接和相关的数据库操作。我们可以通过连接数据库,创建一个用户表,执行增删改查操作。 4. 编写相应的Mapper接口和Mapper映射文件,用于实现与数据库的交互。例如,我们可以定义一个UserMapper接口,其中包括登录、增删改查等方法。 5. 在Spring配置文件中配置相关的Bean,用于连接数据库和处理业务逻辑。这些Bean包括数据源配置、事务管理器、Mapper扫描和连接池等。 6. 在web.xml文件中配置DispatcherServlet和相关的SpringMVC配置。这样,我们的web应用程序就可以通过访问指定的URL来实现登录功能。 7. 编写前端页面,实现用户登录界面。我们可以使用HTML、CSS和JavaScript等技术来设计页面。 8. 最后,我们可以通过源码管理工具(Git或SVN)将项目上传到代码托管平台,然后进行下载。 总结一下,要实现SSM登录、增删查改功能的demo下载,我们需要建立基本的SSM项目,包括配置登录页面和处理登录请求的Controller、配置数据库连接和操作的Mapper接口、配置相关的Bean和配置SpringMVC。最后,编写前端页面和上传代码到代码托管平台,以供下载使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值