标签:jdk har efault row version 1.0 return 准备 support
一 、javaEE的安装及环境配置
工具:
32位系统准备eclipse-jee-mars-2-win32.zip,64位系统准备eclipse-jee-mars-2-win32-x86_64.zip
jdk1.7
maven3.3.9.rar
m2.rar
环境配置:
1. 设置eclipse的配置文件eclipse.ini,修改虚拟机路径,在-vmargs之前添加
-vm E:\jee\jdk1.7\bin\javaw.exe
注意:用写字板打开修改,-vm有的电脑要换行,有的电脑不用换行
2. 启动eclipse,设置maven
在菜单window-prefrences中搜索“maven”,打开“installations”选项进行设置
3.设置maven本地仓库路径
Maven本地仓库默认在C:\Users\用户名\.m2下,C盘空间通常很紧张,需要移到其它盘,步骤如下:
(1)修改Maven根目录(E:\jee\maven-3.3.9)下的 conf文件夹内的setting.xml文件,新增一行:
<localRepository>e:\jee\.m2\repository</localRepository>
(2)修改Eclipse中的maven配置
在菜单window--prefrences中,打开“maven--User settings”,如下图:
先点“User settings”设置项的“Browse…”按钮,选择maven的配置文件,再点下面的“Reindex”按钮更新索引。
二、编写一个简单的加法程序
新建maven项目:
1.选择菜单file—new—maven project,勾选“Create a &simple project (skip archetype selection)"
2.新建maven项目,设置项目属性如下
加法程序关键代码
AddAction.java
package com.cqvie.action; import com.opensymphony.xwork2.ActionSupport; public class AddrAction extends ActionSupport { private String n1; private String n2; private String n; public String getN1() { return n1; } public void setN1(String n1) { this.n1 = n1; } public String getN2() { return n2; } public void setN2(String n2) { this.n2 = n2; } public String getN() { return n; } public void setN(String n) { this.n = n; } /** * 鐧诲綍 * @return */ public String add() { n=n1+n2; return "n"; } }
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"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>登录界面</title> </head> <body> <form action="add" method="post"> name:<input type="text" name="n1" /> name:<input type="text" name="n2" /> <input type="submit" value="=" /> </form> </body> </html>
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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录成功</title>
</head>
<body>
<%-- <s:form action="login" namespace="/" method="post">
<s:textfield name="name" label="name"></s:textfield>
<s:password name="password" label="password"></s:password>
<s:submit value="Login"></s:submit>
</s:form> --%>
<s:property value="n"/>
</body>
</html>
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="struts.multipart.maxSize" value="20971520" /> <constant name="struts.devMode" value="true" /> <package name="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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
</head>
<body>
<a href="login">去登录</a>
</body>
</html>
3.运行项目
选择菜单“Run”—“Run Configurations”,设置如下图:
4.在浏览器中查看结果
地址栏输入“http://localhost:9527/add/”查看结果
标签:jdk har efault row version 1.0 return 准备 support
原文地址:http://www.cnblogs.com/wuwenxin/p/6509031.html