JavaaWeb网站
1.创建包和类
2.编写一个html的文件
<!DOCTYPE Html>
<!--
URL:http://127.0.0.1:8080/demo/login.html
-->
<!-- 指定本文件使用的编码 -->
<meta charset = "UTF-8"/>
<!-- http://127.0.0.1:8080/demo/login.do -->
<form action=".login.do">
<h1>三界姻缘后台管理系统</h1>
<p>
<input type = "text" placeholder = "用户名"/>
</p>
<p>
<input type = "password" placeholder = "密码"/>
</p>
<p>
<button>登录</button>
<div class="wrap">
<form action="/example/html/form_action.asp" method="get">
<p> 用户名: <input type="text" name="name" /></p>
<p> 密码: <input type="text" name="name" /></p>
<p>确认密码: <input type="text" name="name" /></p>
<p>心有灵犀: <input type="text" name="name" /></p>
<p> 性别:<label><input name="Fruit" type="radio" value="" checked />保密 </label>
<label><input name="Fruit" type="radio" value="" />男</label>
<label><input name="Fruit" type="radio" value="" />女 </label>
</p>
<p> 仙历:<select name="select" id="select_k1" class="xla_k">
<option value="请选择">请选择</option>
<option value="公元前10000">公元1000</option>
<option value="公元前1000">公元前100</option>
<option value="公元前100">公元前10</option>
<option value="公元前100">公元前10</option>
<option value="公元前10">公元元年</option>
<option value="公元元年">公元100</option>
<option value="公元100">公元前1000</option>
<option value="公元1000">公元2000</option>
<option value="公元2000">公元3000</option>
<option value="公元3000">公元4000</option>
<option value="公元5000">公元6000</option>
<option value="公元7000">公元不记年</option>
</select>年
<select name="select" id="select_k1" class="xla_k">
<option value="请选择">请选择</option>
<option value="12">12</option>
<option value="11">11</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>月
<select name="select" id="select_k1" class="xla_k">
<option value="请选择">请选择</option>
<option value="31">31</option>
<option value="30">30</option>
<option value="29">29</option>
<option value="28">28</option>
<option value="27">27</option>
<option value="26">26</option>
<option value="25">25</option>
<option value="24">24</option>
<option value="23">23</option>
<option value="22">22</option>
<option value="21">21</option>
<option value="20">20</option>
<option value="19">19</option>
<option value="18">18</option>
<option value="17">17</option>
<option value="16">16</option>
<option value="15">15</option>
<option value="14">14</option>
<option value="13">13</option>
<option value="12">12</option>
<option value="11">11</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
<option value="0">0</option>
</select>日
</p>
</p> 爱好:<input type=checkbox checked> 斗法
<input type=checkbox>游历三界
<input type=checkbox value=1>rap
<input type=checkbox value=1>静禅
<input type=checkbox value=1>悟道
</p>
<p>个人说明:<textarea name="yj" cols="30" rows="6"></textarea>
</p>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body background="timg.jpg">
</body>
</html>
</p>
</form>
html的网页截图
编写网站java代码
package demo;
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.xml.ws.RespectBinding;
//http://127.0.0.1:8080/demo/login.do
@WebServlet("/login.do")
public class LoginServlet implements Servlet{
@Override
public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
String username = req.getParameter("un");
String password = req.getParameter("pw");
System.out.println(username);
System.out.println(password);
resp.getWriter().println(username);
}
@Override
public void destroy() {
}
@Override
public ServletConfig getServletConfig() {
return null;
}
@Override
public String getServletInfo() {
return null;
}
@Override
public void init(ServletConfig config) throws ServletException {
}
}
希望对大家有所帮助