这里写目录标题
1、安装eclipse和Tomcat
1.1、安装方式-略
1.2、配置eclipse的编码格式
1、配置字体大小:Windows-首选项-font-base-textsize
2、jsp调整encoding编码
3、配置全局编码格式Workspace-text file encoding :other=utf-8
2、eclipse如何配置Tomcat服务器server
2.1、操作步骤
1、配置运行时环境,添加
2、选中你的Tomcat版本
3、选中安装目录
4、初始只有jre,要把jdk添加进来,选中installed,选中标准VM
3.6、
3.7、
2.2、为什么要把jre改为jdk
JRE是java运行时环境,包含了java虚拟机,java基础类库,是给用户运行Java程序时使用的
JDK是java开发工具包,是程序员使用java语言编写java程序所需的开发工具包,是提供给程序员使用的,且jdk包含jre
3、创建web项目
4、给web项目添加Tomcat
5、编写一个简单的登陆jsp项目
1、新建一个login.jsp文件
<%@ 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>login</title>
<style type="text/css">
label {display:inline-block;width:100px;}
form {margin:100px auto;width:300px;}
</style>
</head>
<body>
<!--点击登录,是提交给action的值-->
<form action="doLogin.jsp"method="post">
<p>
<label>用户名:</label>
<input type="text" name="username"/>
</p>
<p>
<label>密码:</label>
<input type="password" name="pwd"/>
</p>
<p>
<label></label>
<input type="submit" value="登陆"/>
</p>
</form>
</body>
</html>
2、新建一个doLogin.jsp文件
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
//注意统一编码
request.setCharacterEncoding("utf-8");
//定义两个变量去获取用户名和密码
String username=request.getParameter("username");
String pwd=request.getParameter("pwd");
if("admin".equals(username)&&"123".equals(pwd)){
//如果密码符合,就放入集合
session.setAttribute("loginUser",username);
//弹到欢迎界面
response.sendRedirect("welcome.jsp");
}else{
//错误则弹窗,但是弹窗没有出来
out.print("<script>alter('用户名或密码错误!');location.href='login.jsp'</script>");
}
%>
3、如果登陆成功,则跳转到欢迎界面
<%@ 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>
<h1>欢迎您:<%=session.getAttribute("loginUser")%></h1>
</body>
</html>
6、如何找到项目文件夹
1、如果没有选中第二个,文件夹的位置会有点难找
2、此时可以删除掉原有的服务器
3、选中第二个
4、然后再查看自己的项目是否添加进来
5、运行过后就可以在文件夹里看见自己的文件了