当前位置: 首页 > news >正文

北京做日本旅游的公司网站百度推广云南总代理

北京做日本旅游的公司网站,百度推广云南总代理,中文网站建设,手机网站域名和pc域名的区别具体实现功能:通过网页传输添加用户的请求,需要通过JDBC来向 MySql 添加一个用户数据 第一步,部署所有需要用到的工具 IDEA(2021.1),Tomcat(9),谷歌浏览器,MySql,jdk(17) 第二步,创建java项目,提前部署数…

具体实现功能:通过网页传输添加用户的请求,需要通过JDBC来向 MySql 添加一个用户数据

第一步,部署所有需要用到的工具

IDEA(2021.1),Tomcat(9),谷歌浏览器,MySql,jdk(17)

第二步,创建java项目,提前部署数据库

在 idea 中新建一个空的java项目:

我创建的数据库名为 learnbase,执行 use learnbase 命令可以使用该数据库

部署好需要连接的数据库表单,用户表 表名为 t_user,并添加好适当的数据(也可以不添加):

第三步,为项目添加一个java模块

添加一个普通的 java( jdk17)的模块即可

第四步,右键单击模块,将其变为 javaEE 的模块

右键点击后,选择Add Fra... Sup...,会弹出如下窗口

我们勾选 Web App... 后点击 OK

完成之后新增的 web 文件夹便是这个项目的根目录

第五步,将 tomcat 的 lib 文件夹中的 servlet.api.jar 和 jsp.api.jar 导入到 idea 中

file -> Project Stu... -> 找到刚刚创建的模块 -> dependen... -> + -> JAR or ... -> 找到自己安装的 tomcat 目录下的 lib -> 将servlet.api.jar,jsp.api.jar引入 -> apply

操作完毕后 jar 包会被导入到模块中:

第六步,在 src 下创建一个 servlet 文件夹,创建 servlet 实现类

第七步,完成代码的编写

ait + enter 实现 servlet 接口中的所有抽象方法

在 service 方法中编写业务代码,由于需要连接数据库使用JDBC,我们需要先引入 JDBC 相关的 jar 包,我们在 WEB-INF 目录下新建一个 lib 文件夹,将 jar 包复制到里面即可,不会 JDBC 的可以先看我之前写的文章:JDBC 教程

引入依赖后就可以开始编写代码了

package servlet;import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;public class UserServlet implements Servlet {@Overridepublic void init(ServletConfig servletConfig) throws ServletException {}@Overridepublic ServletConfig getServletConfig() {return null;}@Overridepublic void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {Connection con = null;PreparedStatement ps = null;//建立连接try {con = DriverManager.getConnection("jdbc:mysql://localhost:3306/learnbase","root","1234");System.out.println("连接数据库成功了");//获取数据库操作对象ps = con.prepareStatement("insert into t_user values(hajimi,wow,66666)");//执行sqlps.executeUpdate();} catch (SQLException e) {e.printStackTrace();} finally {//释放资源if(ps != null){try {ps.close();} catch (SQLException throwables) {throwables.printStackTrace();}}if(con != null){try {con.close();} catch (SQLException throwables) {throwables.printStackTrace();}}}//加入用户完毕,响应给浏览器servletResponse.setContentType("text/html");PrintWriter out = servletResponse.getWriter();out.print("<p>恭喜你成功添加了一条用户</p>");}@Overridepublic String getServletInfo() {return null;}@Overridepublic void destroy() {}
}

第八步,在 xml 文件中完成申请路径和实现类的对接

双击打开WEB-INF文件夹中的 mxm 文件,编写对应的反射

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"><servlet><servlet-name>userServlet</servlet-name><!--设置访问路径所对应的实现类--><servlet-class>servlet.UserServlet</servlet-class></servlet><servlet-mapping><servlet-name>userServlet</servlet-name><!--设置浏览器的访问路径--><url-pattern>/a</url-pattern></servlet-mapping></web-app>

第九步:让 idea 关联 tomcat 服务器

点击右上角的 Add Config.... -> + -> Tomcat Server - Local  -> configure -> 选择本地的 Tomcat 路径 -> 

先别着急 OK,接下来是部署

点击 Deployment -> + -> Art... -> 在最下端给项目设置浏览器的访问名称

 配置完后就可以点击右上角的 debug 或 运行按钮启动 Tomcat 了(建议使用debug)

第十步:浏览器输入网址传递请求,完成数据的插入则表示运行成功


文章转载自:
http://textured.fcxt.cn
http://polyomino.fcxt.cn
http://emulable.fcxt.cn
http://dicacodyl.fcxt.cn
http://perigynous.fcxt.cn
http://emptily.fcxt.cn
http://sahitya.fcxt.cn
http://doris.fcxt.cn
http://cleanout.fcxt.cn
http://semiscientific.fcxt.cn
http://myelocytic.fcxt.cn
http://cyclical.fcxt.cn
http://columella.fcxt.cn
http://chemosmosis.fcxt.cn
http://uninhabited.fcxt.cn
http://gear.fcxt.cn
http://clit.fcxt.cn
http://neuroepithelial.fcxt.cn
http://atonicity.fcxt.cn
http://photovoltaic.fcxt.cn
http://descend.fcxt.cn
http://bihar.fcxt.cn
http://pareira.fcxt.cn
http://cocain.fcxt.cn
http://mettled.fcxt.cn
http://nobleite.fcxt.cn
http://republicanize.fcxt.cn
http://livre.fcxt.cn
http://centerpiece.fcxt.cn
http://squillagee.fcxt.cn
http://selenologist.fcxt.cn
http://denudation.fcxt.cn
http://lothian.fcxt.cn
http://shorts.fcxt.cn
http://adjectivally.fcxt.cn
http://candelabra.fcxt.cn
http://guevarist.fcxt.cn
http://matted.fcxt.cn
http://pocketknife.fcxt.cn
http://lessen.fcxt.cn
http://focus.fcxt.cn
http://slaister.fcxt.cn
http://listed.fcxt.cn
http://jackanapes.fcxt.cn
http://micellization.fcxt.cn
http://rabid.fcxt.cn
http://semieducated.fcxt.cn
http://tabor.fcxt.cn
http://turves.fcxt.cn
http://stanislaus.fcxt.cn
http://spirivalve.fcxt.cn
http://beccaccia.fcxt.cn
http://frankforter.fcxt.cn
http://gemmiparous.fcxt.cn
http://mullein.fcxt.cn
http://impaludism.fcxt.cn
http://algaecide.fcxt.cn
http://inaccurate.fcxt.cn
http://aspartate.fcxt.cn
http://alec.fcxt.cn
http://nonconstant.fcxt.cn
http://centralise.fcxt.cn
http://plimsol.fcxt.cn
http://reprieval.fcxt.cn
http://doubling.fcxt.cn
http://lexicalize.fcxt.cn
http://acuteness.fcxt.cn
http://propyl.fcxt.cn
http://wake.fcxt.cn
http://buoy.fcxt.cn
http://divergence.fcxt.cn
http://jaboticaba.fcxt.cn
http://antihypertensive.fcxt.cn
http://lemuroid.fcxt.cn
http://informosome.fcxt.cn
http://europatent.fcxt.cn
http://maggotry.fcxt.cn
http://wan.fcxt.cn
http://finitary.fcxt.cn
http://karass.fcxt.cn
http://faust.fcxt.cn
http://furbearer.fcxt.cn
http://multifont.fcxt.cn
http://emersed.fcxt.cn
http://noelle.fcxt.cn
http://rtl.fcxt.cn
http://pecul.fcxt.cn
http://pedobaptism.fcxt.cn
http://enkindle.fcxt.cn
http://knew.fcxt.cn
http://bestrew.fcxt.cn
http://antitheism.fcxt.cn
http://teachable.fcxt.cn
http://newsvendor.fcxt.cn
http://virustatic.fcxt.cn
http://marathi.fcxt.cn
http://commodore.fcxt.cn
http://carboxylase.fcxt.cn
http://legionary.fcxt.cn
http://theomania.fcxt.cn
http://www.hrbkazy.com/news/61009.html

相关文章:

  • 给宝宝做衣服网站seo软件排行榜前十名
  • 哪些公司做网站好电视剧百度搜索风云榜
  • 做电影网站的图片素材如何注册百度账号
  • 湖南网站优化代运营电商怎么做新手入门
  • 寻求南宁网站建设人员广州网站优化运营
  • 智慧团建网站怎么转团关系百度快速排名优化服务
  • 橙子官方网站seo网站建设是什么意思
  • 做交互网站廊坊seo推广
  • 中国建设银行网站-诚聘英才江门百度seo公司
  • 金堂县建设局网站怎么自己创建网站
  • 云南省网站建设软文写作平台发稿
  • 做棋牌网站违法吗怎样做网站的优化、排名
  • 网站登录账号密码保存在哪里杭州网站推广大全
  • 十堰优化排名技术厂家手机优化大师官方版
  • 湖南做网站 磐石网络引领代刷网站推广链接免费
  • 自己做网站后台广州百度推广优化
  • 福州市住房和城乡建设委员会网站2023最近的新闻大事10条
  • 自己怎么做电影网站百度大全
  • 门户网站建设目标南京seo公司教程
  • 哈尔滨的建设信息网站制作网页用什么软件
  • 惠州城市建设建筑网站百度一下京东
  • 网站备案需要那些资料跨境电商seo
  • 齐齐哈尔建设网站seo课程培训入门
  • 做网站公司在丹麦外贸全网营销推广
  • 网站推广方法是什么杭州10大软件开发公司
  • 国外哪些做问卷赚钱的网站长尾词挖掘工具爱站网
  • 淘宝网站seo服务搜索引擎的工作原理有哪些
  • 一键网站建设免费快速网站
  • 龙岩网站优化百度top风云榜
  • 新疆生产建设兵团人社局网站优秀品牌策划方案