First, the installation of Java EE and environment configuration
Tools:
32-bit System preparation eclipse-jee-mars-2-win32.zip,64-bit system Preparation eclipse-jee-mars-2-win32-x86_64.zip
jdk1.7
Maven3.3.9.rar
M2.rar
Environment configuration:
1. Set the Eclipse profile Eclipse.ini, modify the virtual machine path, and add it before-vmargs
-VM E:\jee\jdk1.7\bin\javaw.exe
Note: Use WordPad to open the changes,-VM some computers to change line, some computers do not need to change line
2. Start eclipse, set up maven
Search for "maven" in the menu window-prefrences, open the "Installations" option to set
3. Set the MAVEN local warehouse path
Maven local warehouse By default under C:\Users\ username \.m2, c disk space is usually very tense and needs to be moved to another disk, the steps are as follows:
(1) Modify the Setting.xml file in the Conf folder under the MAVEN root directory (E:\jee\maven-3.3.9) and add a new line:
<localRepository>e:\jee\.m2\repository</localRepository>
(2) Modifying the MAVEN configuration in eclipse
In the menu window--prefrences, open "Maven--user settings", such as:
Click the "Browse ..." button on the "User settings" setting, select the Maven profile, and then click the "Reindex" button below to update the index.
Second, to write a simple addition program
To create a new MAVEN project:
1. Select Menu File-new-maven project, tick "Create a &simple project (skip archetype selection)"
2. Create a new MAVEN project and set the project properties as follows
Addition Program key Code
Addaction.java
Packagecom.cqvie.action;ImportCom.opensymphony.xwork2.ActionSupport; Public classAddractionextendsActionsupport {PrivateString N1; PrivateString n2; PrivateString N; PublicString getN1 () {returnN1; } Public voidsetN1 (String N1) { This. N1 =Ans; } PublicString getN2 () {returnN2; } Public voidsetN2 (String n2) { This. N2 =N2; } PublicString Getn () {returnN; } Public voidSetn (String N) { This. N =N; } /*** Bnhi 綍 *@return */ PublicString Add () {n=n1+N2; returnN; }}
add.jsp
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 " pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > Name: <input type= "text" name= "N1"/> Name:<input type= "text" name= "n2"/> <input Type= "Submit" value= "="/> </form> </body>
add_success.jsp
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 " pageencoding=" UTF-8 "%><%--<%@ taglib prefix=" s "uri="/struts-tags "%>--% ><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
Struts.xml
<?xml version= "1.0" encoding= "UTF-8"?> <!DOCTYPE Struts public"-//apache software foundation//dtd Struts Configuration 2.0//en" "Http://struts.apache.org/dtds/struts-2.0.dtd" > <struts> <constant name= "struts.i18n.encoding" value= "Utf-8" ></constant> <constant name= "Strut S.multipart.maxsize "value=" 20971520 "/> <constant name=" Struts.devmode "value=" true "/> < PackageName= "P_user" namespace= "/"extends= "Struts-default" > <action name= "Add"class= "Com.cqvie.action.AddAction"Method= "Add" > <result name= "Success" >/add_success.jsp</result> </action> </ Package></struts>
index.jsp
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 " pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
3. Run the project
Choose Menu "Run"-"Run Configurations", set as:
4. View the results in the browser
Address bar Enter "http://localhost:9527/add/" to view results
Write a simple Java EE addition program