Learning is a combination of video books. Look at the books, the knowledge to understand, and use; then watch the video, know how, when watching a video with a 2-3 speed.
Tomcat
Open: bin / startup.bat close: bin / shutdown.bat Note: Linux systems: Open: bin / startup.sh close: bin / shutdown.sh
Modify Pin: conf / server.xml Ctrl + F to find 8080 Note: If the port is 80, can be directly accessed by localhost
Visit: http: // localhost: 8080 / or localhost: 8080 /
Start the Tomcat server in any directory cmd, directly startup open:
1, need to configure the path, plus the path : Installation address ---> D: \ software3 \ apache -tomcat-8.5.40 \ bin;
2, the new environment variable: variable name ----> catalina_home variable value ----> D: \ software3 \ the Apache-Tomcat-8.5.40 // for the installation address
Use cmd in direct catalina Open: catalina RUN stop: catalina STOP
Establish Administrator: conf / tomcat-users.xml
<role rolename="admin-gui"/> <user username="tomcat" password="s3cret" roles="admin-gui"/>
The first javaWeb project: apache-tomcat-8.5.40 \ webapps folder on the inside
Note: requires a standard folder structure:
- *.html,*.jsp,etc
- /WEB-INF/web.xml
- /WEB-INF/classes/
- /WEB-INF/lib
Note: you can achieve fight to save the code is automatically updated sites, you do not need to copy past project.
Basics: http: //www.cnblogs.com/guogangj/p/3725371.html#create-java-web-project
servlet entry: https: //www.cnblogs.com/whgk/p/6399262.html
Note: After running idea, on the Links bar, own branded sayhello (which is inside the web.xml servlet mapping of address)
HTTP: // localhost / SayHello / sayHello (sayHello their own play up)
Note: @WebServlet (name = "DeleteStudentServlet", urlPatterns = "/ DeleteStudentServlet") using @WebServlet without comment and then web.xml Servlet configuration information
JSP request forwarding and redirection:
Forwarding : browser only once request, change the address bar, page after page of forwarding; servlet to send information to a web container, web container and then forwarded to another servlet, it still is the request, the address bar unchanged.
request.getRequestDispatcher("path").foward(request,response)
Redirect : browser two requests, the address bar changes to page after page of forwarding; servlet to send information to a web container, web container to tell the browser to resend the request, the browser sent a new request to change the address bar .
response.sendRedirect("path")
Note: response.sendRedirect ( request.getContextPath () + "/comfirm.jsp"); use absolute paths
JSP directives: the JSP engine designed, does not directly produce a visible output, but tells the engine how to deal with the rest of the JSP page
<% @%> 1.page 2.include 3.taglib three kinds of instructions: include as static comprising
NOTE: WEB-INF generally can not use the address bar to directly access, but can access request is forwarded to. The error page (private files) on the WEB-INF inside,
Note: The contents of JSP page on two things: the module data and elements (including elements have a script, instructions, labels )
Note: Chinese garbage problem: default ISO-8859-1
First layer: the encoding encoding and browser jsp pages unity: UTF-8
Second layer: POST request, before returning to the request information, call request.setCharacterEncoding ( "UTP-8") ; or: the response.setContentType ( "text / HTML; charset = UTF-. 8");
GET requests: Modify the Tomcat server.xml file useBodyEncodeingForURI = "true" to indicate the encoding mode used in the request body
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" useBodyEncodeingForURI="true" />,还要再改Tomcat的xml映射;
(GET or string obtained new String (xxx.getBytes ( "ISO- 8859-1"), "UTF-8"); decoding)
Distortion of an output page for the transmission parameters and distortion
MVC design pattern: Model Control View
The pictures online