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

旅行网站排名前十名郑州网站外包公司简介

旅行网站排名前十名,郑州网站外包公司简介,做网站收会员费,网页制作的视频JSP学习 一、准备我们心爱的IDEA new一个项目:New Project --> Next -->Next -->Finsh 二、配置好服务器Tomcat-9.0.30 1.> 在WEB-INF下创建一个Lib包 将jsp-api.jar复制进去,并使其生效 未生效前: 生效过程: 2.>…
JSP学习

一、准备我们心爱的IDEA

在这里插入图片描述

new一个项目:New Project --> Next -->Next -->Finsh

在这里插入图片描述

二、配置好服务器Tomcat-9.0.30

在这里插入图片描述

1.> 在WEB-INF下创建一个Lib包

将jsp-api.jar复制进去,并使其生效

在这里插入图片描述

未生效前:

在这里插入图片描述

生效过程:

在这里插入图片描述

2.> 用锤子配置汤姆猫TomCat

点击+ 号 选择本地的汤姆猫
在这里插入图片描述

在Deployment中的 + 号 选择Artifat

在这里插入图片描述

将多余的名称删去,为了方便找到

在这里插入图片描述

三、编写JSP文件

1.> 在web包下创建以.jsp为后缀名的文件

在这里插入图片描述

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html><head><title>$Title$</title></head><body>$END$</body>
</html>
2.>语法

JSP注释:为代码作注释以及将某段代码注释掉。

<%-- 该部分注释在网页中不会被显示--%>

<%-- 注释 --%> JSP注释,注释内容不会被发送至浏览器甚至不会被编译

脚本程序的语法格式:

<% 代码片段 %>

JSP表达式

<%= 表达式 %>

四、写个代码爽一下

运行–前提网址正确

1.>求字符串的长度

<%--Created by IntelliJ IDEA.User: 86156Date: 2023/9/4Time: 10:28To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>案例1--求字符串的长度</title>
</head>
<body><%--java代码在下面的标识里面写入<%%>中--%>
<%String str = "hello";out.println("字符串长度为:" + str.length() + ",字符串:" + str);%>
</body>
</html>
运行结果:

网络:http://localhost:8080/FirstWeb2_war_exploded/strlen.jsp

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

2.>计算数组平均值

<%--Created by IntelliJ IDEA.User: 86156Date: 2023/9/18Time: 9:15To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>计算平均值</title>
</head>
<body>
<%int arraySize = 5;int[] numbers = new int[arraySize];numbers[0] = 10;numbers[1] = 20;numbers[2] = 30;numbers[3] = 40;numbers[4] = 50;int sum = 0;for (int i = 0; i < arraySize; i++) {sum += numbers[i];}double average = (double) sum / arraySize;
%>平均值是:<%= average %>
</body>
</html>

http://localhost:8080/FirstWeb2_war_exploded/IntARRay.jsp

在这里插入图片描述

3.>九九乘法表

方式一:
<%--Created by IntelliJ IDEA.User: 86156Date: 2023/9/11Time: 11:16To change this template use File | Settings | File Templates.
--%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head><style>table {border-collapse: collapse;}th, td {border: 1px solid black;padding: 10px;text-align: center;}.odd {background-color: lightblue;}.even {background-color: lightgreen;}</style>
</head>
<body>
<table><tr><th></th><% for (int i = 1; i <= 9; i++) { %><th><%= i %></th><% } %></tr><% for (int i = 1; i <= 9; i++) { %><tr><th><%= i %></th><% for (int j = 1; j <= 9; j++) { %><% int result = i * j; %><td class="<%= (i + j) % 2 == 0 ? "even" : "odd" %>"><%= i %> * <%= j %> = <%= result %></td><% } %></tr><% } %>
</table>
</body>
</html>

http://localhost:8080/FirstWeb2_war_exploded/multitable1.jsp

在这里插入图片描述

方式二:
<%--Created by IntelliJ IDEA.User: 86156Date: 2023/9/11Time: 10:55To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head><style>table {border-collapse: collapse;}th, td {border: 1px solid black;padding: 10px;text-align: center;}.odd {background-color: lightblue;}.even {background-color: lightgreen;}</style>
</head>
<body>
<table><tr><th></th><% for (int i = 1; i <= 9; i++) { %><th><%= i %></th><% } %></tr><% for (int i = 1; i <= 9; i++) { %><tr><th><%= i %></th><% for (int j = 1; j <= 9; j++) { %><% int result = i * j; %><% if (j >= i) { %><td class="<%= (i + j) % 2 == 0 ? "even" : "odd" %>"><%= i %> * <%= j %> = <%= result %></td><% } else { %><td></td><% } %><% } %></tr><% } %>
</table>
</body>
</html>

http://localhost:8080/FirstWeb2_war_exploded/multitalbe2.jsp

在这里插入图片描述

4.>获取圆的面积:

STEP1:编写一个圆的类

在src下,new一个包,包下new一个class文件为circle

如图:

在这里插入图片描述

写好私有域的r,利用ptg快速生成JavaBean (ptg可以在插件中下载)

在这里插入图片描述

package cn.heima.circle2;public class Circle {private  double r;public Circle() {}public Circle(double r) {this.r = r;}/*** 获取* @return r*/public double getR() {return r;}/*** 设置* @param r*/public void setR(double r) {this.r = r;}public String toString() {return "Circle{r = " + r + "}";}public  double getAreacIR(){return  Math.PI*this.r*this.r;}
}
STEP2:在JSP文件下导入Circle文件:

导入方法

<%@ page import="cn.heima.circle2.Circle" %>
<%--Created by IntelliJ IDEA.User: 86156Date: 2023/9/11Time: 11:27To change this template use File | Settings | File Templates.
--%>
<%--Created by IntelliJ IDEA.User: 86156Date: 2023/9/11Time: 11:27To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="cn.heima.circle2.Circle" %>
<html>
<head><title>CircleDemo</title>
</head>
<body>
<%Circle c = new Circle(1.0);out.print(c.getAreacIR());
%>
</body>
</html>

结果

在这里插入图片描述

http://www.yayakq.cn/news/649454/

相关文章:

  • 网站建设哪家公司便宜有什么要求
  • 南京成旭通网站建设公司怎么样网络广告营销的概念
  • 做本地房产网站微信小程序注册流程
  • 对php网站开发技术课程总结可上传多个视频的网站建设
  • 网站建设服务费属于什么科目wordpress远程下载
  • 深圳建设网站速成班水头哪里有做网站的
  • 广州微信网站开发公司志鸿优化网
  • 搭建网站架构怎么做怎么去创立一个网站
  • 江苏省国家示范校建设专题网站wordpress仿知乎
  • 设计网站p站腾讯云 wordpress 主题
  • html5 公众号 网站开发wordpress如何关闭自动更新
  • 潍坊高端网站建设网站建设浙江公司
  • 网站什么意思织梦网站 防黑
  • 网站开发做什么科目开发平台价格
  • 武钢建设公司网站做网站还有流量么
  • 给公司做网站销售怎样啦网站流量指标
  • 火蝠电商seo搜索排名优化方法
  • 如何用frontpage做网站网站免费搭建平台
  • 网站建设物美价廉企业门户网站需求模板
  • 南阳网站排名公司做平台外卖的网站需要什么资质
  • 查看wordpress主题台州网站推广优化
  • 临海市住房和城乡建设规划局 网站免费建站软件哪个好
  • 资源共享网站建设网站上传到虚拟空间
  • 国外做网站公司能赚钱音乐网站的音乐列表如何做
  • 龙岗网站设计机构合肥做网站的公司有哪些
  • 芜湖集团网站建设微网站建设加盟
  • 帮别人做网站进了看守所简单的网页设计作品源代码
  • 10月哪个网站做电影票活动网站风格优势
  • 泰安网站建设xtempire能赚钱的网站
  • 发布信息的网站自己建的网站如何百度搜索