//得到class类
//1.
Class re = reflection.class;
//2.
re = new reflection().getClass();
//3.
re=Class.forName("WebServer.reflection");
//实例化
reflection r=(reflection)re.getConstructor().newInstance();
Extensible Markup Language 可扩展标记语言,作为数据的一种存储格式或用于存储软件的参数,程序解析此配置文件,就可以到达不修改代码就更改程序的目的。
<persons>
<person>
<name>至尊宝name>
<age>1000age>
person>
<person>
<name>白晶晶name>
<age>7000age>
person>
persons>
public class Person {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
public class PersonHandler extends DefaultHandler{
List<Person> persons;
Person person;
String tag;
@Override
public void startDocument() throws SAXException {
persons = new ArrayList<>();
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if(qName!=null)
{
tag=qName;
}
if(qName.equals("person"))
{
person = new Person();
}
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
if(tag!=null&&tag.equals("name")) {
person.setName(new String(ch,start,length));
}
if(tag!=null&&tag.equals("age")) {
person.setAge(Integer.valueOf(new String(ch,start,length)));
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if(qName.equals("person"))
{
this.persons.add(person);
}
tag=null;
}
public List<Person> getPersons() {
return persons;
}
}
//获取解析工厂
SAXParserFactory factory = SAXParserFactory.newInstance();
//工厂解析器
SAXParser parse = factory.newSAXParser();
//注册处理器
PersonHandler handler=new PersonHandler();
//加载文档Document
parse.parse(Thread.currentThread().getContextClassLoader().getResourceAsStream("WebServer/test.xml"), handler);
//处理数据
List<Person> persons = handler.getPersons();
for(Person p:persons)
{
System.out.println(p.getName()+" "+p.getAge());
}
<form method action>
<input type name id/>
form>
method 请求方式:get数据量小,安全性低,默认方式;post数据量大,相对安全
action 请求服务器路径
id 用户浏览器区分唯一性,即编号,前端区分唯一值
name 名称,后端服务器区分唯一性获取值
只要提交数据给后台,必须存在name
一般name,id名一致
超文本传输协议
1.请求方式:方法 URI 协议/版本POST /index.html HTTP/1.1
2.请求头 Date,Server,Content-type,Content-length
3.请求正文
请求方式 | POST /answer.html HTTP/1.1 |
---|---|
请求头 | Host: localhost:8888 Content-Type: application/x-www-form-urlencoded |
Origin: null
Cookie: _ga=GA1.1.2027630145.1526140932; yjs_id=138bb94205173dee10fe75efb9049ddb
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15
Content-Length: 21
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate |
| 请求内容 | uname=admin&pwd=admin (post方式才有) |
1.HTTP协议版本 状态代码 描述:HTTP/1.1 200 OK
2.响应头
3.响应正文 …
Web.xml—>webHandler->webContent->webApp->Servlet(LoginServlet,RegisterSrevlet)->Dispater->server