Java,
Java,
Java注意事项:
标识符的命名:
Java语言中,对于变量,常量,函数,语句块也有名字,我们统统称之为Java标识符. 标识符是用来给类、对象、方法、变量、接口和自定义数据类型命名的。
标识符的命名规则:
命名上可以看出一个程序员的好坏。
1.Java标识符由数字,字母和下划线(_),美元符号($)或人民币符号(¥)组成
2.Java中是区分大小写的,而且还要求首位不能是数字。最重要的是,Java关键字不能当作Java标识符。
3.类和接口名。每个字的首字母大写,含有大小写。例如,MyClass,HelloWorld,Time等。
4.方法名。首字符小写,其余的首字母大写,含大小写。尽量少用下划线。例如,myName,setTime等。这种命名方法叫做驼峰式命名。
5.常量名。基本数据类型的常量名使用全部大写字母,字与字之间用下划线分隔。对象常量可大小混写。例如,SIZE_NAME。
6.变量名。可大小写混写,首字符小写,字间分隔符用字的首字母大写。不用下划线,少用美元符号。给变量命名是尽量做到见名知义。
—————————————————————————————————————————————————————————————————————————————
服务器:
硬件服务器,软件服务器(软硬构成一套体系); Web服务器是运行及发布Web应用的容器,只有将开发的Web项目放置到该容器中,才能使网络中的所有用户通过浏览器进行访问。
开发Java Web应用所采用的服务器主要是与JSP/Servlet兼容的Web服务器,比较常用的有Tomcat、Resin、JBoss、WebSphere 和 WebLogic 等,下面将分别进行介绍。
Tomcat 服务器
目前最为流行的Tomcat服务器是Apache-Jarkarta开源项目中的一个子项目,是一个小型、轻量级的支持JSP和Servlet 技术的Web服务器,也是初学者学习开发JSP应用的首选。
Resin 服务器
Resin是Caucho公司的产品,是一个非常流行的支持Servlet和JSP的服务器,速度非常快。Resin本身包含了一个支持HTML的Web服务器,这使它不仅可以显示动态内容,而且显示静态内容的能力也毫不逊色,因此许多网站都是使用Resin服务器构建。
JBoss服务器
JBoss是一个种遵从JavaEE规范的、开放源代码的、纯Java的EJB服务器,对于J2EE有很好的支持。JBoss采用JML API实现软件模块的集成与管理,其核心服务又是提供EJB 服务器,不包含Servlet和JSP的Web容器,不过它可以和Tomcat完美结合。
WebSphere 服务器
WebSphere是IBM公司的产品,可进一步细分为 WebSphere Performance Pack、Cache Manager 和WebSphere Application Server等系列,其中WebSphere Application Server 是基于Java 的应用环境,可以运行于 Sun Solaris、Windows NT 等多种操作系统平台,用于建立、部署和管理Internet和Intranet Web应用程序。 WebLogic 服务器
WebLogic 是BEA公司的产品,可进一步细分为 WebLogic Server、WebLogic Enterprise 和 WebLogic Portal 等系列,其中 WebLogic Server 的功能特别强大。 WebLogic 支持企业级的、多层次的和完全分布式的Web应用,并且服务器的配置简单、界面友好。对于那些正在寻求能够提供Java平台所拥有的一切应用服务器的用户来说,WebLogic是一个十分理想的选择。
默认端口号:
1、Tomcat 默认端口号8080
2、MySQL 默认端口号3306
3、SqlServer 默认端口号 1433
4、Http 默认端口号 80 常用服务和开放端口对照表
http://jingyan.baidu.com/article/03b2f78c498da25ea237aeb8.html
————————————————————————————————————————————————————————————————————————————
MyEclipse:
在Java中,main()方法是Java应用程序的入口方法,也就是说,程序在运行的时候,第一个执行的方法就是main()方法,这个方法和其他的方法有很大的不同,比如方法的名字必须是main,方法必须是public static void 类型的,方法必须接收一个字符串数组的参数等等。
————————————————————————————————————————————————————————————————————————————
HTML
html:
- GET - 从指定的资源请求数据。
- POST - 向指定的资源提交要被处理的数据
GET:
- GET 请求可被缓存
- GET 请求保留在浏览器历史记录中(数据会裸露在URL中)
- GET 请求可被收藏为书签
- GET 请求不应在处理敏感数据时使用
- GET 请求有长度限制
- GET 请求只应当用于取回数据
POST:
- POST 请求不会被缓存
- POST 请求不会保留在浏览器历史记录中
- POST 不能被收藏为书签
- POST 请求对数据长度没有要求(可以发大数据GET不可以)
标签
DIV: 块级标签(独占一行) SPAN:
行级标签(不独占行)
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
package com.ser;
import java.util.Scanner;
public class text {
//把1234拆分倒叙输出
/*
* 4
* 3
* 2
* 1
*
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int shu = input.nextInt();
int a = shu%10;
int b = shu/10%10;
int c = shu/100%10;
int d = shu/1000%10;
System.out.print(a);
System.out.print(b);
System.out.print(c);
System.out.print(d);
//阶乘
int tame = 1,sun=0;
for(int i=1;i<=15;i++){
for(int j=1;j<=i;j++){
tame*=j;
}
System.out.println(i+"的阶乘"+sun);
sun+=tame;
tame=1;
}
System.out.println(sun);
//九九乘法表
for(int i=1;i<10;i++){
for(int j=1;j<=i;j++){
System.out.print(j+"*"+i+"="+(j*i<10?" "+j*i:j*i)+"\t");
if(i*j<10){
System.out.print(j+"*"+i+"="+" "+i*j+"\t");
}else{
System.out.print(j+"*"+i+"="+i*j+"\t");
}
}
System.out.println();
}
//金字塔
String daxie="";
for(int i=65;i<=90;i++){
daxie+=(char)i;
}
System.out.println(daxie);
char ch = 'A';
int n=25;
for(int i = 0;i<=n;i++){
if(i==1){
for(int j=1;j<=2*(n-i)-1;j++){
System.out.print(" ");
}
}else{
for(int j=1;j<=2*(n-i);j++){
System.out.print(" ");
}
}
if(i==1){
System.out.print(ch);
}else{
for(int k=1;k<=2*(i-1);k++){
System.out.print(ch+" ");
}
}
System.out.println();
ch++;
}
for(int i=0;i<20;i++){
for(int j=20;j>i;j--){
System.out.print(" ");
}
if(i==0){
System.out.println("A");
continue;
}
for(int j=1;j<=2*i-2;j++){
System.out.print("a");
}
System.out.println();
}
}
}
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>用户注册</title>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<style type="text/css">
input{
height: 25px;
width: 170px;
}
</style>
<!-- 导入工具js文件 -->
<script type="text/javascript" src="js/tool.js"></script>
<!-- 单个验证 -->
<script type="text/javascript">
function writeEach(id){
var message = "";
if(id == "email"){
message = "<b style='color:green'>请填写你的常用邮箱</b>";
}
if(id == "nickname"){
message = "<b style='color:green'>最多26个字符,一个汉字占两个字符</b>";
}
if(id == "pwd"){
message = "<b style='color:green'>以字母开头,6~16个字符</b>";
}
if(id == "confirm"){
message = "<b style='color:green'>请再填写一次密码";
}
var spanId = id + "Error";
document.getElementById(spanId).innerHTML = message;
}
function checkEach(id,value){
value = trim(value);
var message = "<img src='image/right.jpg'/>";
if(id == "email" && value == ""){
message = "<img src='image/wrong.jpg'/><b style='color:red'>邮箱是必填的</b>";
}else if(id == "email" && !checkEmailFormat(value)){
message = "<img src='image/wrong.jpg'/><b style='color:red'>邮箱格式不正确</b>";
}
if(id == "nickname" && value == ""){
message = "<img src='image/wrong.jpg'/><b style='color:red'>昵称是必填的</b>";
}
if(id == "pwd" && value == ""){
message = "<img src='image/wrong.jpg'/><b style='color:red'>密码是必填的</b>";
}else if(id == "pwd" && value.length > 16){
message = "<img src='image/wrong.jpg'/><b style='color:red'>太长了,最多16个字符</b>";
}else if(id == "pwd" && value.length <6){
message = "<img src='image/wrong.jpg'/><b style='color:red'>太短了,最少6个字符</b>";
}
if(id == "confirm" && value == ""){
message = "<img src='image/wrong.jpg'/><b style='color:red'>请输入确认密码</b>";
}else if(id == "confirm" && value != document.getElementById("pwd").value){
message = "<img src='image/wrong.jpg'/><b style='color:red'>两次密码不一致</b>";
}
var spanId = id + "Error";
document.getElementById(spanId).innerHTML = message;
}
</script>
<!-- 整体验证 -->
<script type="text/javascript">
function checkAll(){
var flag = true;
var email = document.getElementById("email").value;
alert(email);
email = trim(email);
if(email == ""){
document.getElementById("emailError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>邮箱是必填的</b>";
flag = false;
}else if(!checkEmailFormat(email)){
document.getElementById("emailError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>邮箱格式不正确</b>";
flag = false;
}
var nickname = document.getElementById("nickname").value;
nickname = trim(nickname);
if(nickname == ""){
document.getElementById("nicknameError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>昵称是必填的</b>";
flag = false;
}
var pwd = document.getElementById("pwd").value;
pwd = trim(pwd);
if(pwd == ""){
document.getElementById("pwdError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>密码是必填的</b>";
flag = false;
}else if(pwd.length > 16){
document.getElementById("pwdError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>太长了,最多16个字符</b>";
flag = false;
}else if(pwd.length < 6){
document.getElementById("pwdError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>太短了,最少6个字符</b>";
flag = false;
}
var confirm = document.getElementById("confirm").value;
confirm = trim(confirm);
if(confirm == ""){
document.getElementById("confirmError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>请输入确认密码</b>";
flag = false;
}else if(confirm != document.getElementById("pwd").value){
document.getElementById("confirmError").innerHTML =
"<img src='image/wrong.jpg'/><b style='color:red'>两次密码不一致</b>";
flag = false;
}
return flag;
}
</script>
</head>
<body>
<h1 align="center">用户注册</h1>
<hr>
<form id="regForm" name="regForm"
method="get" action="http://www.baidu.com" onsubmit="return checkAll()">
<table>
<tr>
<td>邮箱:</td>
<td><input type="text" id="email" name="email" onfocus="writeEach(this.id)" onblur="checkEach(this.id,this.value)"/>
<span id="emailError"></span></td>
</tr>
<tr>
<td>昵称:</td>
<td><input type="text" id="nickname" name="nickname" onfocus="writeEach(this.id)" onblur="checkEach(this.id,this.value)"/>
<span id="nicknameError"></span></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" id="pwd" name="pwd" onfocus="writeEach(this.id)" onblur="checkEach(this.id,this.value)"/>
<span id="pwdError"></span></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="password" id="confirm" name="confirm" onfocus="writeEach(this.id)" onblur="checkEach(this.id,this.value)"/>
<span id="confirmError"></span></td>
</tr>
</table>
<input type="submit" value="注册新用户"/>
</form>
<hr>
</body>
</html>
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
相关文章
- 暂无相关文章
用户点评