To facilitate the modification and subsequent packaging routines
First user visited page from Web. Xml to find <welcome-file-list><welcome-file>index.html</welcome-file></ Welcome-file-list> Welcome page settings, this can set a limited access to the page, here is index.html then the user can be sent through the index.html of the parent request as a form form submitted address/manage/user/ Index maps to Userservlet to get the data <servlet><servlet-name>userservlet</servlet-name><servlet-class >com.linyi.controller.UserServlet</servlet-class></servlet><servlet-mapping>< servlet-name>userservlet</servlet-name><url-pattern>/manage/user/index</url-pattern></ Servlet-mapping> then Uiserservlet inherits HTTPSERVLT replication Doget or Dopost method public class Userservlet extends HttpServlet {// Iuserservice iuserservice = new Userserviceimpl () Iuserservice iuserservice = beanfactory.getinstance ("UserService", Iuserservice.class); @Overrideprotected void Doget (HttpServletRequest req, HttpServletResponse resp) throws Servletexception, IOException {list<user> users = iuserservice.getusers (); Req.setattribute ("Users", users); This.getservletconfig (). GetservLetcontext (). Getrequestdispatcher ("/users/index.jsp"). Forward (REQ,RESP);}} Here called Userserviceimpl gets and forwards to the users/index.jsp page after coming to Userserviceimpliuserdao Iuserdao = Beanfactory.getinstance (" Userdao ", Iuserdao.class), @Overridepublic list<user> getusers () {return iuserdao.getallusers ();} @Overridepublic void AddUser (String name) throws Userexception{int re = Iuserdao.adduser (name), if (re!=0) {throw new Userexception ("Insert data Exception" +name);}} public void UpdateUser (int id,string name) {iuserdao.updateuser (id,name);} @Overridepublic user selectuser (int id) throws Userexception {//user user = Iuserdao.selectuser (ID), if (User = = null) {thro W New Userexception ("Data not Found" +id); Else{return user;}} Here called the Userdaoimpl to get the value of this Userdao to manipulate the database instantiation of the User wrapper class, in order to get the value returned to the page public list<user> getAllUsers () {//Connect to the database List <User> users = new arraylist<user> ();//Connect database try {class.forname ("com.mysql.jdbc.Driver"); Connection Connection = drivermanager.getconnection ("Jdbc:mysql://localhost/student", "root", "root"); String sql = "SELECT * from EMP"; PreparedStatement preparestatement = connection.preparestatement (sql); ResultSet ResultSet = Preparestatement.executequery (); while (Resultset.next ()) {int id = resultset.getint (1); String name = resultset.getstring (2); User user = new user (id,name); users.add (user);}} catch (Exception e) {e.printstacktrace ();} return users;} @Overridepublic int AddUser (String name) {try {class.forname ("com.mysql.jdbc.Driver"); Connection Connection = drivermanager.getconnection ("Jdbc:mysql://localhost/student", "root", "root"); String sql = "INSERT into emp VALUES ('" +name+ "')"; PreparedStatement preparestatement = connection.preparestatement (sql);p Reparestatement.execute ();} catch (Exception e) {e.printstacktrace (); return-1;} return 0;} public void UpdateUser (int id,string name) {try {class.forname ("com.mysql.jdbc.Driver"); Connection Connection = drivermanager.getconnection ("Jdbc:mysql://localhost/student", "root", "root"); String sql = "UPDATE emp set name= '" +name+ "' where id=" +iD+ ""; PreparedStatement preparestatement = connection.preparestatement (sql);p Reparestatement.execute ();} catch (Exception e) {e.printstacktrace ();}} @Overridepublic user selectuser (int id) {User user = Null;try {class.forname ("com.mysql.jdbc.Driver"); Connection Connection = drivermanager.getconnection ("Jdbc:mysql://localhost/student", "root", "root"); String sql = "select* from emp WHERE ' id ' =" +id; PreparedStatement preparestatement = connection.preparestatement (sql); ResultSet set = Preparestatement.executequery (), while (Set.next ()) {int id2 = Set.getint (1); String name = set.getstring (2); user = new User (id2,name);}} catch (Exception e) {e.printstacktrace ();} Return user; requestscope.message how to use Required Autofocus HTML5 <input> AutoComplete, required, autofocus properties Input:focus 1. Specify whether the input field should enable auto-completion the property value on off auto-complete allows the browser to predict input to the field. When the user starts typing in the field, the browser should display the options that are filled in the field, based on the values that were previously typed. Note: The AutoComplete property applies to the form, as well as the following input types: text, search, URL, telephone, email, password, datepickers, range, and color. 2, required= "required" provisions must be completed before submitting the input field. If you use this property, the field is required (or required). Note: The Required property applies to the following input types: text, search, URL, telephone, email, password, date pickers, number, checkbox, radio, and file. 3, Aotofocus automatically get focus 4, styleinput:focus{background-color:yellow;} /style current input Get focus background color change yellow lose focus change default
Java EE, including js,html,jsp and so on knowledge integration