Java creates a war package and publishes it to a linux server

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
insert image description here
insert image description here
under src under java Resource Create a package, then create a service in the package
insert image description here
insert image description here
and click finish to complete the creation
insert image description here
. 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);	

insert image description here

Create a simple jsp file in the foreground, place it under WebContent, write a form in it to submit data to the background,
insert image description here
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
insert image description here

insert image description here
Then run to see the effect
insert image description here

Then enter this URL in the browser: http://localhost:8080/Test02/index.jsp
insert image description here
insert image description here
and upload it to your server:
1. First open the war package
insert image description here
insert image description here
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/
insert image description here

Then add the following to the Host tag in server.xml:

insert image description here
insert image description here

Then enter the console to restart tomcat once (note that I entered the bin directory of tomcat for the operation)
insert image description here
insert image description here

After submitting, you will see the data you want, which means success.
insert image description here

Guess you like

Origin blog.csdn.net/qq_49249150/article/details/121338782