日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringMVC简单项目配置

發(fā)布時間:2025/3/21 javascript 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringMVC简单项目配置 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

一、首先,SpringMVC框架使用分層開發(fā),分層是為了實現(xiàn)“高內(nèi)聚,低耦合”。采用“分而治之”的思想,把問題劃分開來各個解決,易于控制,延展和分配資源,最重要的是有利于后期項目維護。MVC是指Model(模型)、View(視圖)、Controller(控制器),在SpringMVC的編程中一般具有四層,分別是:

表示層:(jsp、html)主要就是界面的展示

控制層:(Contoller、Action)控制界面跳轉(zhuǎn)

業(yè)務(wù)層:(Service)調(diào)用DAO層,實現(xiàn)解耦合目的,雖然不要它也可以運行項目,但是會使項目后期的延展和維護變得困難

持久層:(DAO)也叫數(shù)據(jù)訪問層,實現(xiàn)對數(shù)據(jù)庫的訪問

二、然后,注解的使用,在SpringMVC中經(jīng)常用到注解,使用注解可以極大的節(jié)省開發(fā)者的時間,下面是幾個最重要的注解介紹:

@Repository:標(biāo)注數(shù)據(jù)訪問層,可以告訴SpringMVC這是一個數(shù)據(jù)訪問層,并將其申明為一個bean,例如UserDao接口的實現(xiàn)類UserDaoImpl,在類上加注解@Repository("userDao"),bean的名稱為userDao

@Service:標(biāo)注業(yè)務(wù)層,例如UserService接口的實現(xiàn)類,在類上加@Service("userService"),bean的名稱為userService

@Controller:控制層,在控制層類上加@Controller即可,確認(rèn)其是一個控制層類

@Component:當(dāng)不確定是屬于哪層是用這個注解

三、說的再多,不如做一遍,下面是一個簡單的跳轉(zhuǎn)并實現(xiàn)登錄功能的SpringMVC項目的介紹

1.項目環(huán)境搭建,在eclipse下點擊左上角File→New→Dynamic Web Projiect,創(chuàng)建項目MySpringMVC,新建項目結(jié)構(gòu)如下

?在lib下導(dǎo)入jar包,在這里,需要的jar包有哪些就不介紹了,反正是能多不能少,多了不會報錯,不明白就都弄進去吧。在WEB-INF下新建web.xml文件

?

[html]?view plaincopy
  • <?xml?version="1.0"?encoding="UTF-8"?>??
  • <web-app?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"??
  • ????xmlns="http://java.sun.com/xml/ns/javaee"???
  • ????xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"??
  • ????xsi:schemaLocation="http://java.sun.com/xml/ns/javaee?http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"??
  • ????id="WebApp_ID"?version="3.0">??
  • ????<!--處理從頁面?zhèn)鬟f中文到后臺而出現(xiàn)的中文亂碼問題?-->??
  • ??????<!--?encoding?start?-->??
  • ??<filter>??
  • ????<filter-name>encodingFilter</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>??
  • ????<init-param>??
  • ??????<param-name>forceEncoding</param-name>??
  • ??????<param-value>true</param-value>??
  • ????</init-param>??
  • ??</filter>???
  • ??<filter-mapping>??
  • ????<filter-name>encodingFilter</filter-name>??
  • ????<url-pattern>/*</url-pattern><!--?對所有文件過濾?-->??
  • ??</filter-mapping>??
  • ??<!--?encoding?ends?-->??
  • ??<!--?首頁設(shè)置?-->??
  • <welcome-file-list>??
  • ????<welcome-file>index.jsp</welcome-file>??
  • </welcome-file-list>??
  • </web-app>??
  • 在WebContent下建一個index.jsp

    [html]?view plaincopy
  • <%@?page?language="java"?contentType="text/html;?charset=UTF-8"??
  • ????pageEncoding="UTF-8"%>??
  • <!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>welcome</title>??
  • </head>??
  • <body>??
  • ????This?is?MySpringMVC!??
  • </body>??
  • </html>??
  • 用tomcat運行項目,最好做每一步都運行下,看能通過不,不然后面很難發(fā)現(xiàn)錯誤

    ?

    接下來實現(xiàn)頁面的跳轉(zhuǎn)在index.jsp里加入

    ?

    [html]?view plaincopy
  • <a?href="toLogin.do">登錄</a>??
  • ?

    在WEB-INF下新建文件夾webPage,然后建立Login.jsp

    ?

    [html]?view plaincopy
  • <%@?page?language="java"?contentType="text/html;?charset=UTF-8"??
  • ????pageEncoding="UTF-8"%>??
  • <!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="userLogin.do"?method="post">??
  • <input?type="hidden"?name="categoryId"?value="1"?/>??
  • ??
  • ??
  • <div?class="login">??
  • ??<div?class="loginleft">??
  • ?????<p?class="logotext">MySpringMVC登錄界面</p>??
  • ???</div>??
  • ???<div?class="loginright">??
  • ?????<p?class="loginrighttit">用戶登錄</p>??
  • ?????<ul>??
  • ???????<li><p>用&nbsp;&nbsp;戶&nbsp;&nbsp;名:</p>?<input?name="userName"?id="userName"?type="text"/>??
  • ???????</li>??
  • ???????<li><p>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;碼:</p>?<input?name="loginPassword"?id="loginPassword"?type="password"/>??
  • ???????</li>??
  • </ul>??
  • ?????<p><input?name=""?type="submit"?value="登&nbsp;&nbsp;錄"?class="loginrightbutton"?/></p>??
  • ???</div>???
  • </div>??
  • </form>??
  • </body>??
  • </html>??
  • 在WEB-INF下建立文件夾xmlConfig,創(chuàng)建webConfig.xml

    ?

    ?

    [html]?view plaincopy
  • <?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"??
  • ????xsi:schemaLocation="??
  • ????????http://www.springframework.org/schema/beans???????
  • ????????http://www.springframework.org/schema/beans/spring-beans-3.0.xsd??
  • ????????http://www.springframework.org/schema/context???
  • ????????http://www.springframework.org/schema/context/spring-context-3.0.xsd">??
  • ????<!--?視圖解釋類?-->????
  • ????<bean?id="viewResolver"??
  • ????????class="org.springframework.web.servlet.view.InternalResourceViewResolver">??
  • ????????<property?name="viewClass"???
  • ????????value="org.springframework.web.servlet.view.JstlView"/>??
  • ????????<property?name="prefix">??
  • ????????????<value>/WEB-INF/webPage/</value>??
  • ????????</property>??
  • ????????<property?name="suffix">??
  • ????????????<value>.jsp</value>??
  • ????????</property>??
  • ????</bean>??
  • </beans>??
  • 在web.xml中添加配置文件

    ?

    ?

    [html]?view plaincopy
  • <!--?SpringMVC??DispatcherServlet配置?-->??
  • <servlet>??
  • ????<servlet-name>spring</servlet-name>??
  • ????<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>??
  • ????<init-param>??
  • ????????<param-name>contextConfigLocation</param-name>??
  • ????????<param-value>/WEB-INF/xmlConfig/webConfig.xml</param-value>??
  • ????</init-param>??
  • ????<load-on-startup>1</load-on-startup>??
  • </servlet>??
  • <!--?springmvc?請求后綴?-->??
  • <servlet-mapping>??
  • ????<servlet-name>spring</servlet-name>??
  • ????<url-pattern>*.do</url-pattern><!--?攔截所有以.do結(jié)尾的請求,交于DispatcherServlet處理?-->??
  • </servlet-mapping>??
  • 在src中建立com.user.action包,創(chuàng)建UserAction類

    ?

    [java]?view plaincopy
  • package?com.user.action;??
  • ??
  • import?org.springframework.stereotype.Controller;??
  • import?org.springframework.ui.ModelMap;??
  • import?org.springframework.web.bind.annotation.RequestMapping;??
  • ??
  • @Controller??
  • //標(biāo)明這是一個控制層類??
  • public?class?UserAction?{??
  • ????@RequestMapping(value?=?"/toLogin.do")??
  • ????//響應(yīng)index.jsp的登錄請求??
  • ????public?String?login(ModelMap?map){????
  • ????????return?"/Login";??
  • ????}??
  • }??
  • 在webConfig里添加

    [html]?view plaincopy
  • <!--?自動掃描的包名?,掃描控制層-->????
  • ???<context:component-scan?base-package="com.user.action"></context:component-scan>????
  • 運行項目,結(jié)果如下

    ?

    點擊登錄,界面跳轉(zhuǎn)

    2.以上是SpringMVC一個簡單環(huán)境的配置,接下來是數(shù)據(jù)庫的連接,需要在lib下導(dǎo)入mysql的jar包,下面是做一個簡單的登錄功能,采用mysql數(shù)據(jù)庫,建立如下包結(jié)構(gòu),有利于分層開發(fā)

    在WEB-INF下建立文件夾properties,建立db.properties,保存數(shù)據(jù)庫配置信息,配置的信息一定不要錯了,這里是我事先建好的一個test數(shù)據(jù)庫,在里面建了個user表,id,name,password三個字段

    [html]?view plaincopy
  • #myspring?Mysql數(shù)據(jù)庫配置??
  • driver=com.mysql.jdbc.Driver??
  • url=jdbc:mysql://localhost:3306/test??
  • user=root??
  • password=123456??
  • 在WEB-INF/xmlConfig文件夾下建立globalAppliacation.xml

    ?

    ?

    [html]?view plaincopy
  • <?xml?version="1.0"?encoding="UTF-8"?>??
  • <beans?xmlns="http://www.springframework.org/schema/beans"??
  • ????xmlns:security="http://www.springframework.org/schema/security"??
  • ????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:context="http://www.springframework.org/schema/context"??
  • ????xmlns:jee="http://www.springframework.org/schema/jee"?xmlns:mvc="http://www.springframework.org/schema/mvc"??
  • ????xsi:schemaLocation="????
  • ????????http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-3.1.xsd??
  • ????????http://www.springframework.org/schema/mvc?http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd????
  • ????????http://www.springframework.org/schema/security?http://www.springframework.org/schema/security/spring-security-3.1.xsd????
  • ????????http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop-3.1.xsd????
  • ????????http://www.springframework.org/schema/tx?http://www.springframework.org/schema/tx/spring-tx-3.1.xsd????
  • ????????http://www.springframework.org/schema/cache?http://www.springframework.org/schema/cache/spring-cache-3.1.xsd????
  • ????????http://www.springframework.org/schema/jdbc?http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd????
  • ????????http://www.springframework.org/schema/jee?http://www.springframework.org/schema/jee/spring-jee-3.1.xsd????
  • ????????http://www.springframework.org/schema/jms?http://www.springframework.org/schema/jms/spring-jms-3.1.xsd????
  • ????????http://www.springframework.org/schema/lang?http://www.springframework.org/schema/lang/spring-lang-3.1.xsd????
  • ????????http://www.springframework.org/schema/oxm?http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd????
  • ????????http://www.springframework.org/schema/task?http://www.springframework.org/schema/task/spring-task-3.1.xsd????
  • ????????http://www.springframework.org/schema/util?http://www.springframework.org/schema/util/spring-util-3.1.xsd??
  • ????????http://www.springframework.org/schema/context?http://www.springframework.org/schema/context/spring-context-3.1.xsd">??
  • ????<!--?Activates?scanning?of?@Service?-->????
  • ????<context:component-scan?base-package="com.user.service"/>???
  • ????<!--?Activates?scanning?of?@Repository?-->????
  • ????<context:component-scan?base-package="com.user.dao"/>??
  • ????<!--?加載屬性文件,分散配置解析?-->??
  • ????<!--?======================================================================================?-->??
  • ????<context:property-placeholder?location="/WEB-INF/properties/*.properties"?/>??
  • ????<!--?======================================================================================?-->??
  • ????<!--?配置?數(shù)據(jù)源?連接池?c3p0?-->??
  • ????<!--?======================================================================================?-->??
  • ????<!--?讀寫數(shù)據(jù)源?-->??
  • ????<bean?id="dataSource"?class="com.mchange.v2.c3p0.ComboPooledDataSource"??
  • ????????destroy-method="close">??
  • ????????<property?name="driverClass"?value="${driver}"></property>??
  • ????????<property?name="jdbcUrl"?value="${url}"></property>??
  • ????????<property?name="user"?value="${user}"></property>??
  • ????????<property?name="password"?value="${password}"></property>??
  • ????</bean>??
  • ????<!--?配置jdbc模板類jdbcTemplate?-->??
  • ?????<bean?id="film-template"?class="org.springframework.jdbc.core.JdbcTemplate">????
  • ?????<property?name="dataSource"?ref="dataSource"/>????
  • ???</bean>????
  • </beans>??
  • 在web.xml中加入如下代碼

    ?

    ?

    [html]?view plaincopy
  • ????<!--?ContextLoaderListener的作用就是啟動Web容器時,自動裝配ApplicationContext的配置信息?-->??
  • <listener>??
  • ????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>??
  • </listener>??
  • <!--?加載配置文件?-->??
  • <context-param>??
  • <param-name>contextConfigLocation</param-name>??
  • <param-value>??
  • /WEB-INF/xmlConfig/globalApplication.xml??
  • </param-value>??
  • </context-param>??
  • 在com.user.vo中建立類UserVo,這是一個實體類

    [java]?view plaincopy
  • package?com.user.vo;??
  • ??
  • public?class?UserVo?{??
  • ????private?int?id;??
  • ????private?String?name;??
  • ????private?String?password;??
  • ????public?int?getId()?{??
  • ????????return?id;??
  • ????}??
  • ????public?void?setId(int?id)?{??
  • ????????this.id?=?id;??
  • ????}??
  • ????public?String?getName()?{??
  • ????????return?name;??
  • ????}??
  • ????public?void?setName(String?name)?{??
  • ????????this.name?=?name;??
  • ????}??
  • ????public?String?getPassword()?{??
  • ????????return?password;??
  • ????}??
  • ????public?void?setPassword(String?password)?{??
  • ????????this.password?=?password;??
  • ????}??
  • ??????
  • }??
  • 然后在com.user.dao中建立接口UserDao

    [java]?view plaincopy
  • package?com.user.dao;??
  • ??
  • import?com.user.vo.UserVo;??
  • ??
  • public?interface?UserDao?{??
  • ????public?UserVo?login(UserVo?u);??
  • }??
  • 在com.user.dao.impl中實現(xiàn)這個接口,類UserDaoImpl

    ?

    ?

    [java]?view plaincopy
  • package?com.user.dao.impl;??
  • ??
  • import?java.sql.ResultSet;??
  • import?java.sql.SQLException;??
  • import?java.util.List;??
  • ??
  • import?org.springframework.beans.factory.annotation.Autowired;??
  • import?org.springframework.beans.factory.annotation.Qualifier;??
  • import?org.springframework.jdbc.core.JdbcTemplate;??
  • import?org.springframework.jdbc.core.RowMapper;??
  • import?org.springframework.stereotype.Repository;??
  • ??
  • import?com.user.dao.UserDao;??
  • import?com.user.vo.UserVo;??
  • @Repository("userDao")??
  • public?class?UserDaoImpl?implements?UserDao{??
  • ????@Autowired??
  • ????@Qualifier("film-template")//名字跟xml中配置的id要一致??
  • ???????/*?封裝一個JdbcTemplate的模板對象?*/????
  • ????private?JdbcTemplate?jdbcTemplate;????
  • ????
  • ????/*?通過set方法注入進來即可?*/????
  • ????public?JdbcTemplate?getJdbcTemplate()?{??
  • ????????return?jdbcTemplate;??
  • ????}??
  • ????public?void?setJdbcTemplate(JdbcTemplate?jdbcTemplate)?{??
  • ????????this.jdbcTemplate?=?jdbcTemplate;??
  • ????}??
  • ????@Override??
  • ????public?UserVo?login(UserVo?u)?{??
  • ????????String?sql="select?*?from?user?where?name=??and?password=?";??
  • ????????Object[]?param?=?new?Object[]{u.getName(),u.getPassword()};??
  • ????????List<UserVo>?la?=?jdbcTemplate.query(sql,param,new?RowMapper<UserVo>()?{??
  • ????????????????????public?UserVo?mapRow(ResultSet?rs,?int?i)??
  • ????????????????????????????throws?SQLException?{??
  • ????????????????????????UserVo?vo?=?new?UserVo();??
  • ????????????????????????vo.setId(rs.getInt("id"));??
  • ????????????????????????vo.setName(rs.getString("name"));??
  • ????????????????????????vo.setPassword(rs.getString("password"));??
  • ????????????????????????return?vo;??
  • ????????????????????}??
  • ????????????????});??
  • ????????if(la!=null&&la.size()>0){??
  • ????????????return?la.get(0);??
  • ????????}else{??
  • ????????????return?null;??
  • ????????}??
  • ????}??
  • ??
  • }??
  • 接口類UserService

    ?

    ?

    [java]?view plaincopy
  • package?com.user.service;??
  • ??
  • import?com.user.vo.UserVo;??
  • ??
  • public?interface?UserService?{??
  • ????public?UserVo?login(UserVo?u);??
  • }??
  • 實現(xiàn)類UserServiceImpl

    ?

    ?

    [java]?view plaincopy
  • package?com.user.service.impl;??
  • ??
  • import?org.springframework.beans.factory.annotation.Autowired;??
  • import?org.springframework.beans.factory.annotation.Qualifier;??
  • import?org.springframework.stereotype.Service;??
  • ??
  • import?com.user.dao.UserDao;??
  • import?com.user.service.UserService;??
  • import?com.user.vo.UserVo;??
  • @Service("userService")??
  • public?class?UserServiceImpl?implements?UserService{??
  • ????@Autowired??
  • ????@Qualifier("userDao")??
  • ????private?UserDao?userDao;??
  • ????public?UserDao?getUserDao()?{??
  • ????????return?userDao;??
  • ????}??
  • ????public?void?setUserDao(UserDao?userDao)?{??
  • ????????this.userDao?=?userDao;??
  • ????}??
  • ????@Override??
  • ????public?UserVo?login(UserVo?u)?{??
  • ????????//?TODO?Auto-generated?method?stub??
  • ????????return?userDao.login(u);??
  • ????}??
  • ??
  • }??
  • 在UserAction中新建一個方法

    [java]?view plaincopy
  • package?com.user.action;??
  • ??
  • import?java.io.IOException;??
  • ??
  • import?javax.servlet.http.HttpServletRequest;??
  • import?org.springframework.beans.factory.annotation.Autowired;??
  • import?org.springframework.beans.factory.annotation.Qualifier;??
  • import?org.springframework.stereotype.Controller;??
  • import?org.springframework.ui.ModelMap;??
  • import?org.springframework.web.bind.annotation.RequestMapping;??
  • import?org.springframework.web.bind.annotation.RequestMethod;??
  • ??
  • import?com.user.service.UserService;??
  • import?com.user.vo.UserVo;??
  • @Controller??
  • public?class?UserAction?{??
  • ????@Autowired???
  • ????@Qualifier("userService")??
  • ????private?UserService?userService;??
  • ??????
  • ????public?UserService?getUserService()?{??
  • ????????return?userService;??
  • ????}??
  • ????public?void?setUserService(UserService?userService)?{??
  • ????????this.userService?=?userService;??
  • ????}??
  • ????UserVo?u=new?UserVo();??
  • ????@RequestMapping(value?=?"/toLogin.do",?method?=?{RequestMethod.GET,RequestMethod.POST?})??
  • ????public?String?login(ModelMap?map,HttpServletRequest?request)?throws?IOException{??????
  • ????????return?"/Login";??
  • ????}??
  • ????@RequestMapping(value="/userLogin",?method?=?{RequestMethod.GET,RequestMethod.POST?})??
  • ????public?String?loginCheck(ModelMap?map,HttpServletRequest?request)?throws?IOException{??
  • ????????String?name=request.getParameter("userName");//獲取Login.jsp傳送過來的參數(shù)??
  • ????????String?password=request.getParameter("loginPassword");??
  • ????????u.setName(name);??
  • ????????u.setPassword(password);??
  • ????????UserVo?vo=userService.login(u);//通過業(yè)務(wù)層實現(xiàn)對數(shù)據(jù)訪問層的訪問??
  • ????????if(vo==null)??
  • ????????????return?"/error";??
  • ????????else??
  • ????????????System.out.println(vo.getId());??
  • ????????????map.addAttribute("id",vo.getId());//向前臺傳送一個名字為id的參數(shù),若能成功得到值,證明成功訪問數(shù)據(jù)庫??
  • ????????return?"/success";??
  • ??????????
  • ????}??
  • }??
  • 在webPage下建一個success.jsp,登錄成功跳轉(zhuǎn)到該界面

    ?

    ?

    [html]?view plaincopy
  • <%@?page?language="java"?contentType="text/html;?charset=UTF-8"??
  • ????pageEncoding="UTF-8"%>??
  • <!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>Insert?title?here</title>??
  • </head>??
  • <body>??
  • ????成功,用戶的ID為${id}??
  • </body>??
  • </html>??
  • 再建一個error.jsp,登錄失敗跳轉(zhuǎn)到該界面

    ?

    ?

    [html]?view plaincopy
  • <%@?page?language="java"?contentType="text/html;?charset=UTF-8"??
  • ????pageEncoding="UTF-8"%>??
  • <!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>Insert?title?here</title>??
  • </head>??
  • <body>??
  • ????失敗!??
  • </body>??
  • </html>??
  • ?

    下面是數(shù)據(jù)庫user表中的數(shù)據(jù)信息

    輸入用戶名admin,密碼123456.點擊登錄

    ?

    獲取參數(shù)用戶ID是2,數(shù)據(jù)庫連接成功,登錄相當(dāng)于一個查詢操作,只要數(shù)據(jù)庫能連通,其他刪除,修改,添加操作都挺容易的

    轉(zhuǎn)載于:https://www.cnblogs.com/zhaoyan001/p/7513781.html

    總結(jié)

    以上是生活随笔為你收集整理的SpringMVC简单项目配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。