:
conn=/H/sapserver&clnt=200&user=mis08?=zh&expert=true其中:XXX是你的SAP系统的名字,sapserver是服务器的名字,clnt是client,user是登陆的用户名字3,执行ln
-s
//bin/guilogon
/usr/bin/guilogon,建立guilogon的快捷方式,其中是你的SAPGUI的安装路径4,打开etc目录下的hosts文件,把SAP服务器的信息加进去如:
172.16.100.253
sapserver5,执行guilogon,就会出现和sapgui
for
windows一样的窗口了,里面有SAP系统列表,可以选择登陆进去了
页面jsp文件<form name="add" action="/gxtWeb/lvjcontacts/manyContacts.action" method="post"enctype="multipart/form-data" onsubmit="return checkNull()">
<s:file name="upload"></s:file>
<input type="submit" value="导入信息" >
</form>
action处理:
public class ManyContactsAction extends ActionSupport {
private File upload
private String uploadContentType// 要上传的文件的类型
private String uploadFileName// 要上传的文件
private ContactsManager manager
private Contacts cbean
private Persons pbean
private Long gid
private String result
public String execute() throws Exception {
// 检查后缀名是否符合条件,同时更改上传文件的文件名
int filesize = this.getUploadFileName().length()
String fileEx = this.getUploadFileName().substring(
this.getUploadFileName().indexOf("."), filesize)
//获取文件名
String fileName=uploadFileName.substring(0,uploadFileName.indexOf("."))
// 获得上传路径
String realPath = ServletActionContext.getServletContext().getRealPath(
"/UploadFile/")
File saveFile=null
if (upload != null) {
// 修改文件名,使上传后不至于重复替代
// this.uploadFileName = new Date().getTime() + fileEx
saveFile = new File(new File(realPath), uploadFileName)
if (!saveFile.getParentFile().exists()) {
saveFile.getParentFile().mkdirs()
}
FileUtils.copyFile(upload, saveFile)// 到这里,文件已上传成功
// 下面进行判断文件是否是rar文件,是就需要解压
if (fileEx.equals(".rar")) {
System.out.println("saveFile:" + saveFile)//rar文件所在保存路径
System.out.println("realPath:" + realPath)//解压后保存路径
// 定义解压字符串,用于解压上传的rar文件,注意此处需要一个unrar.exe文件
String rarpath = ServletActionContext.getServletContext()
.getRealPath("/rarFile/UNRAR.exe x -t -o+ -p- \"")
String jieya = rarpath + saveFile + "\" \"" + realPath + "\""
Process p1 = Runtime.getRuntime().exec(jieya)// 将传输的rar文件解压
p1.waitFor()
p1.destroy()
FileUtils.deleteQuietly(saveFile)// 删除rar文件
saveFile=new File(new File(realPath),fileName+".xls")
System.out.println("解压后:"+saveFile)
ServletActionContext.getResponse().getWriter().println(
"success!!")
}
if (fileEx.equals(".xls") || fileEx.equals(".xlsx")) {
// 开始读取文件了,获得第一列手机号码
Workbook persons = Workbook.getWorkbook(saveFile)// 获得xls文件
Sheet sheet = persons.getSheet(0)// 获得第一个工作簿
System.out.println("列数:" + sheet.getColumns())
int count = sheet.getRows()// 取得记录数,count行
String cphone
// 遍历行,获得列数据
for (int i = 0i <counti++) {
cphone = sheet.getCell(0, i).getContents()// 第一列的所有行
pbean = manager.getPerson(cphone)// 获得该用户,查询别的信息
cbean = new Contacts()
Long contactsid = pbean.getId()
Long pid = 10002L
cbean.setContactsid(contactsid)// 联系人id
cbean.setPid(pid)// 用户本身的PID
cbean.setCid("cid")// 关系的学校ID
cbean.setGid(gid)// 分组id
manager.addPerson(cbean)
this.contactsLog.writeLog("10002", "批量添加联系人", "批量添加联系人操作","")
System.out.println("添加成功!")
}
}
return SUCCESS
} else {
return INPUT
}
}
}
xml配置:
<action name="manyContacts" class="manyContactAction">
<result name="success" type="redirectAction">personInfo.action
</result>
<result name="input" type="redirectAction">showmangpersons.action
</result>
</action>