- environment configuration
- required software: Maven eclipse-mars jdk1.7 (This software is green version, no need to install).
- unzip maven, Eclipse-mars , jdk1.7, centralized to a folder for easy management, such as the author of this time to all the software, files to focus on x: \jee folder.
- above is the equivalent of eliminating the installation process and unnecessary hassle, and then there are some changes to make. In eclipse eclipse.ini, modify the virtual machine path, -vmargs before adding -VM X:\jee\jdk1.7\bin\javaw.exe ( X for your drive letter).
Note: Open the changes with WordPad,-vm do not break the line
- Start Eclipse-mars, set maven. (Hint: You can create a corresponding workspace in the Jee folder before starting workspace, copy the good path, the first boot can be pasted up, check the activation, save some trouble.) )
search for "maven" in the menu window-prefrences and open the "Installations" option to set it up. Maen-> installations
and then tap installations–> add selects the MAVEN installation directory, for example here the author's installation directory is X:\jee\maven-3.2.9.
Note: after maven has been added to the list, don't forget to tick to enable.
Then, we are Maven Configuration Interface, set user Settings
Global Settings Select settings.xml under the Conf folder in the Maven installation directory , where my maven installation directory is x:\ Maven-3.2.9\conf\settings.xml, select your Maven installation directory and check the Local Repository entry if it is x:\ Maven-3.2.9\repository is configured successfully, otherwise reconfigure the previous step.
Above, the environment configuration is basically complete.
Project Building
First select the menu File-new-maven project and tick the "Create a &simple project (skip archetype selection)" Entry:
New Maven project, after creating a new project, first configure the Web. XML (web-inf directory) file to find <welcome-file> modify the name and file name of the new page you created </welcome-file> I'm creating an add
The code is as follows:
<%@ 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" >
(Note: The value of the name attribute in the input tag must be the same as the value in the new Java program)
Then create a new Java program to perform the addition of numbers, with the following specific code:
Packagecom.cqvie.action;ImportCom.opensymphony.xwork2.ActionSupport; Public classUseractionextendsActionsupport {Private intnum1, num2, sum; Public intgetNum1 () {returnNUM1; } Public voidSETNUM1 (intNUM1) { This. NUM1 =NUM1; } Public intgetNum2 () {returnnum2; } Public voidSETNUM2 (intnum2) { This. num2 =num2; } Public intgetsum () {returnsum; } Public voidSetsum (intsum) { This. sum =sum; } PublicString Add () {sum= Num1 +num2; return"Success"; } }
Note the newly created file inherits the Actionsupport
The top 2 programs have the main page, the addition of the program is also available, the next is to receive the added value after the
Create a new JSP file named Add_success, with the following code:
// receive the results of the addition </body >
Finally configure the Stracts.xml file
Its configured code is as follows:
<struts> <constant name= "struts.i18n.encoding" value= "Utf-8" ></constant> <constant name= " Struts.multipart.maxSize "value=" 20971520 "/> <constant name=" Struts.devmode "value=" true "/> < Packageextends= "Struts-default" > class= "Com.cqvie.action.AddAction" Method= "Add" > <result name= "Success" > /add_success.jsp </result> </action> </Package ></struts>
The addition program succeeds here and then runs:
Run-run configurations
The above is complete.
--software 152 bindings Xu Hao
Learning Note--maven+eclipse Java EE instance: addition Calculator