If you have not configured the server, please skip here to configure: https://editor.csdn.net/md/?articleId=121337669
The steps after that are:
1. Open eclipse or idea, create a javaweb project
under src under java Resource Create a package, then create a service in the package
and click finish to complete the creation
. Make a slight modification and add this string of code:
//输入输出的编码格式
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
//根据前台传过来的name进行获取input里面的数据
String sr = request.getParameter("names");
System.out.println(sr);
//将获取到的数据穿到前台去
PrintWriter out = response.getWriter();
out.print("您输入的是:"+sr);
Create a simple jsp file in the foreground, place it under WebContent, write a form in it to submit data to the background,
and then add the web project to tomcat. If you have not configured tomcat, please enter this link to see how to configure
https: //editor.csdn.net/md/?articleId=108117875
Then run to see the effect
Then enter this URL in the browser: http://localhost:8080/Test02/index.jsp
and upload it to your server:
1. First open the war package
and finish after the selection is complete, and then go to the place where you saved it to find This war package
and then upload the war package to the server with wscp or xftp, under tomcat/webapps/
Then add the following to the Host tag in server.xml:
Then enter the console to restart tomcat once (note that I entered the bin directory of tomcat for the operation)
After submitting, you will see the data you want, which means success.