项目分析

1.深圳移动无线市民主页
1.我负责的主要是应用管理,账号管理,Tips管理,其中应用管理包括应用新增,应用查询,应用新增里面可以添加
(新增版本(1.0,1.1),推荐指数(只能输入1-3位整数)类型(android,iphone(选择andoird时把软件路径显示,把iphone路径隐藏,否则反之)
-->js style.disply="",block不兼容火狐,none)--->页面震动(30%)),软件路径(request.getSession().getServletContext.getRealPath+File.separator)
软件Logo(实际上保存的是logo的路径),应用查询主要根据软件名称查询,再根据推荐指数,日期倒序排列

2.无线城市接口笔记
// 动态密码接口(解析properties,properties文件保存一段url,再通过InputStream fis = new FileInputStream(path+ConfigFileName);
Io流解析,HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();之后返回路径,最后out.println出去)
@RequestMapping("/dynamicPassword.do")
public void dynamicPassword(HttpServletRequest request,
HttpServletResponse response, ModelMap map) throws SQLException,
UnsupportedEncodingException {
request.setCharacterEncoding("UTF-8");
String id = request.getParameter("id");
String auth = request.getParameter("auth");
String mobile = request.getParameter("mobile");
Properties props = new Properties();
PrintWriter out = null;
try {
String path = this.getClass().getClassLoader().getResource("/")
.getPath();
try {
path = URLDecoder.decode(path, "utf-8");

} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
InputStream fis = new FileInputStream(path+ConfigFileName);

props.load(fis);
Enumeration en = props.propertyNames();
String key = null;
String value = null;
while (en.hasMoreElements()) {
key = (String) en.nextElement();
if (key.equals(dynamicURL)) {
value = props.getProperty(key);
break;
}
}
if (!value.contains("?")) {
value += "?";
}
value += "id=" + id;
value += "&auth=" + auth;
value += "&mobile=" + mobile;
String result = inGet(value);
response.setContentType("text/html;charset=UTF-8");
out = response.getWriter();
out.println(result);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (out != null) {
out.flush();
out.close();
}
}
}
//软件升级接口
(首先取出用户的imei,电话号码,version(版本),取出用户的版本号,跟服务器上的版本对比,
如果服务器上的版本低于客户版本就升级,
另外可以根据带过来的参数决定是否强制升级,如果是强制升级,result返回0,否则返回1
再用StringBUilder拼凑url,然后out出去)
@RequestMapping("/Upgrade.do")
public String upgrade(HttpServletRequest request,HttpServletResponse response,ModelMap map) throws SQLException {
String imei = (String)request.getParameter("imei");//用户
String mobile = (String)request.getParameter("mobile");//电话号码
String version = (String)request.getParameter("version");//软件版本号
StringBuffer sb= new StringBuffer();
sb.append("<?xml version='1.0' encoding='UTF-8'?>");
sb.append("<soarsky>");
String _version =null;
String force=null;
List<Map<String,String>> list =userDao.queryUserVersion();
if(null != list && list.size()>0)
{
Map versionMap=list.get(0);
force=versionMap.get("FORCE").toString();
int version_1=getVersion(version);

_version="V"+versionMap.get("V")+"R"+versionMap.get("R")+"A"+versionMap.get("A")+"P"+versionMap.get("P");
int version_2=getVersion(_version);

if(version_1>=version_2)
{
sb.append("<upgrade result=\"3\">");
sb.append("<tip>您已经是最新版本了</tip>");
sb.append("</upgrade>");
}
else
{
if(force.equals("0"))
{
sb.append("<upgrade result=\"0\">");
}
else
{
sb.append("<upgrade result=\"1\">");
}
sb.append("<version>"+_version+"</version>");
sb.append("<filesize>"+versionMap.get("FILESIZE")+"</filesize>");
// List<Map<String,String>> url= userDao.queryUserInfo();
sb.append("<updateUrl>"+versionMap.get("URL")+"</updateUrl>");
sb.append("</upgrade>");

}


}
sb.append("</soarsky>");
try {
response.setContentType("text/xml");
OutputStream out =response.getOutputStream();
out.write(sb.toString().getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
}

return null;
}
(首先获取带过来的电话号码,电话类型,然后根据参数查询返回List,再遍历list,在拼接url,最后out出去)
// 客户端请求精彩推荐列表
@RequestMapping("/getCommendList.do")
public String getCommendList(HttpServletRequest request,
HttpServletResponse response, ModelMap map) throws SQLException {
String sofit = (String) request.getParameter("mobile");// 电话号码
String phone_type = (String) request.getParameter("phone_type");
String page = (String) request.getParameter("page");// 开始记录
String count = (String) request.getParameter("count");// 结尾记录
int end = Integer.parseInt(page) * Integer.parseInt(count);
int start = (Integer.parseInt(page) - 1) * Integer.parseInt(count) + 1;
Map lmap = new HashMap();
lmap.put("start", start);
lmap.put("end", end);
lmap.put("phone_type", phone_type);
List list = userDao.querySoft(lmap);
StringBuffer sb = new StringBuffer();
sb.append("<?xml version='1.0' encoding='UTF-8'?>");
sb.append("<soarsky>");
sb.append("<messageCode>200</messageCode>");
sb.append("<message>请求成功</message>");
for (int i = 0; i < list.size(); i++) {
Map custMap = (Map) list.get(i);
sb.append("<soft>");
sb.append("<softid>"+String.valueOf( custMap.get("SOFTID")).trim()+"</softid> ");
sb.append("<softlogo>" +String.valueOf( custMap.get("LOGO")).trim() + "</softlogo>");
sb.append("<softname>" + String.valueOf(custMap.get("SOFTNAME")).trim() + "</softname>");
sb.append("<scorelevel>" +String.valueOf( custMap.get("SCORE")).trim() + "</scorelevel>");
sb.append("<isfree>" +String.valueOf( custMap.get("ISFREE")).trim() + "</isfree>");
sb.append("<softpath>" + String.valueOf(custMap.get("URL")).trim() + "</softpath>");
sb.append("</soft>");
}
sb.append("</soarsky>");
try {
response.setCharacterEncoding("utf-8");
response.setContentType("text/xml");
OutputStream out = response.getOutputStream();
out.write(sb.toString().getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
}

return null;
}


// 评论列表接口
@RequestMapping("/getcommentList.do")
public String getcommentList(HttpServletRequest request,
HttpServletResponse response, ModelMap map) throws SQLException {
String phoneType = (String) request.getParameter("softid").trim();
String softid = (String) request.getParameter("softid").trim();// 电话号码
String page = (String) request.getParameter("page");// 开始记录
String count = (String) request.getParameter("count");// 结尾记录

int end = Integer.parseInt(page) * Integer.parseInt(count);
int start = (Integer.parseInt(page) - 1) * Integer.parseInt(count) + 1;
Map lmap = new HashMap();
lmap.put("softid", softid);
lmap.put("start", start);
lmap.put("end", end);
lmap.put("phoneType", phoneType);
List list = userDao.queryComment(lmap);
int commentcount = userDao.queryCommentCount(lmap);
StringBuffer sb = new StringBuffer();
sb.append("<?xml version='1.0' encoding='UTF-8'?>");
sb.append("<soarsky>");
sb.append("<messageCode>200</messageCode>");
sb.append("<message>请求成功</message>");
String content=null;
for (int i = 0; i < list.size(); i++) {
Map custMap = (Map) list.get(i);
content=String.valueOf(custMap.get("CONTENT"));
if(content!=null)
{
content=URLDecoder.decode(content);
System.out.println("解码:"+content);
}
sb.append("<comment>");
sb.append("<content><![CDATA[" +content + "]]></content>");
sb.append("<phone><![CDATA[" + String.valueOf(custMap.get("PHONE")).trim() + "]]></phone>");
sb.append("<publishtime><![CDATA[" + String.valueOf(custMap.get("CREATEDATE")).trim()+ "]]></publishtime>");
sb.append("</comment>");
}
sb.append("<total>" + commentcount + "</total>");
sb.append("</soarsky>");
try {
response.setContentType("text/xml");
OutputStream out = response.getOutputStream();
out.write(sb.toString().getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
}

return null;
}

/**
* 请求解析数据流
*
* @param strurl
* @param content
* @return
*/
public String inGet(String strurl) {
try {
URL url = new URL(strurl);
System.out.println("URL:" + strurl);
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

int code = httpURLConnection.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
return convertStreamToString(httpURLConnection.getInputStream());
} else {
return "";
}
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

/**
* 将输入流转成字符串
*
* @param is
* @return
*/
public String convertStreamToString(InputStream is) {
/*
* To convert the InputStream to String we use the
* BufferedReader.readLine() method. We iterate until the BufferedReader
* return null which means there's no more data to read. Each line will
* appended to a StringBuilder and returned as String.
*/
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();

String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}

return sb.toString();
}
}

2.中国电信广研院AR平台
1.频道供应商关系管理(频道跟内容提供商是一对多的关系),内容供应商包括:新浪生活,四维地图,开开周边,号百服务 ,
频道(都市生活)包括:频道名称,频道id,频道生活
2POI信息分类(id,名称)供应商关系管理(poi(分类)包括:食宿 ,购物 ,文化等),内容供应商包括:新浪生活,四维地图,开开周边,号百服务 ,
POI信息分类跟内容提供商是多对多的关系
接口实现:
1.获取频道内容接口
(根据childid查询出频道内容,用Sax解析,方法封装转成json格式)
/**
* 获取频道内容
*
* @return
*/
public String getCpContent() {
Map<String, Object> jsonObj = new HashMap<String, Object>();
String resultcode = "0";
String resultmsg = "error";
String total = "0";
String count = "0";
String page = "1";
if (!"".equals(chid) && chid != null) {
TbContentCp tb = cpService.getCpById(chid);
countChannel(chid);// 统计频道访问次数
SAXReader reader = new SAXReader();
try {
if (tb != null && tb.getCpurl().length() > 0) {
InputStream in = inPost(FormatURL(tb.getCpurl()), "");
System.out.println("URL==="+FormatURL(tb.getCpurl()));
if (in != null) {
Document doc = reader.read(in);
Element xml = doc.getRootElement();
resultcode = xml.elementText("resultcode");
resultmsg = xml.elementText("resultmsg");
total = xml.elementText("total");
count = xml.elementText("count");
page = xml.elementText("page");
Element date = xml.element("date");
Element poilist = date.element("poilist");
if (poilist != null) {
@SuppressWarnings("unchecked")
List<Element> list = poilist.elements("content");
List<POIBean> resultMap = new ArrayList<POIBean>();
if (list != null && list.size() > 0) {
for (Element content : list) {
POIBean pb = new POIBean();
pb.setCategory(content.elementText("category"));
pb.setName(content.elementText("name"));
pb.setIntroduction(content
.elementText("introduction"));
pb.setPic_url(content
.elementText("pic_url"));
pb.setAddress(content
.elementText("address"));
pb.setLatitude(content
.elementText("latitude"));
pb.setLongitude(content
.elementText("longitude"));
List<Map<String, String>> operate = new ArrayList<Map<String, String>>();
@SuppressWarnings("unchecked")
List<Element> operatelist = content
.elements("operate");
if (operatelist != null
&& operatelist.size() > 0) {
String lable, action, contentStr;
for (Element op : operatelist) {
Map<String, String> operaM = new HashMap<String, String>();
lable = op.elementText("lable");
action = op.elementText("action");
contentStr = op.elementText("content");
operaM.put("lable", lable);
operaM.put("action", action);
operaM.put("content", contentStr);
if (lable.length() > 0
&& action.length() > 0
&& contentStr.length() > 0) {
operate.add(operaM);
}
}
pb.setOperate(operate);
}
resultMap.add(pb);
}
jsonObj.put("poilist", resultMap);
}
}
}
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
resultcode = "0";
resultmsg = "error";
e.printStackTrace();
} finally {
jsonObj.put("resultcode", resultcode);
jsonObj.put("resultmsg", resultmsg);
jsonObj.put("total", total);
jsonObj.put("count", count);
jsonObj.put("page", page);
jsonObj.put("keywords", keywords);
this.setXml(JsonUtil.toJson(jsonObj));
}
} else {
jsonObj.put("resultcode", resultcode);
jsonObj.put("resultmsg", resultmsg);
jsonObj.put("total", total+"");
jsonObj.put("count", count);
jsonObj.put("page", page);
jsonObj.put("keywords", keywords);
this.setXml(JsonUtil.toJson(jsonObj));
}

return SUCCESS;
}
2.获取所有频道接口
(查询出所有频道list,解析list,用jsonObject封装,最后out出去)
/**
* 获取所有频道
*
* @return
*/
public String getAllChannel() {
log.debug("interface getAllChannel start");
JSONObject jsonObj = new JSONObject();
try {
List<TbContentChannel> channelList = channelService
.getAllTbContentChannel();
List<Map<String, String>> resultMap = new ArrayList<Map<String, String>>();
for (int i = 0; i < channelList.size(); i++) {
Map<String, String> channelMap = new HashMap<String, String>();
channelMap.put("id", channelList.get(i).getId());
channelMap.put("channelname", channelList.get(i)
.getChannelname());
resultMap.add(channelMap);
}
jsonObj.put("channellist", resultMap);
jsonObj.put("resultcode", "1");
jsonObj.put("resultmsg", "ok");
this.setXml(jsonObj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
return SUCCESS;
}
3.珠海转换器项目(金融)
报文结构:
报文头 报文类型标识符 位 图 报文域
报文中使用位图来标识报文中有哪些域而没有哪些域。一个报文中可以有一个或两个位图位图在报文中位置如图所示:
报文头 报文类型标识符 位 图 报文域
(ThreadPoolNumberThree)线程池类用于接收来自Loadrunner来的报文,并发送给远程主机
定义一个方法用于用于接收来自远程主机来的报文
将从远程主机处理过的报文返回给Loadrunner
TransmitMachine
Socket,多线程
4.前海人寿(保险)
1.应付账款流程(用户登录后可以查看自己的应付账款,然后发给相关处理人处理,用户还可以看到自己的流程到哪一步了)
Jdeveloper,oracle ,存储过程(带参数的存储过程),function函数,weblogic(发布,把工程加到域里,domain)
5.电子商务(购物车)
主要做了购物车,处理sesion问题:禁止cookie,关闭浏览器是否保存session等等
session的作用,生命周期
session的原理
session使用细节,多浏览器共享session
重启浏览,关闭cookie的话无解
禁用cookie了--->解决方案 重写URL --->response.encodeURL
("day07/servlet/SessionDemo1");
response.encodeRedirectURL("day07/servlet/SessionDemo1");
javascript:void(0) //去掉超链接默认行为
//手工以cooie形式发sessionid,以解决关闭浏览器后,上次买的东西还在
(cooike未禁用)
客户端防表单重复提交和服务器端session防表单重复提交(服务器有延迟)
El表达式用于获取数据(${data})
6 总结
Session将信息保存在服务器上,而Cookie保存在客户端上
Session比Cookie更安全,Session比Cookie更占资源
开发原则:Session要尽量少用--尽量少向Session中保存信息
session使用了Cookie的机制,如果Cookie被禁用,则Session也无法使用,因
为客户端的session ID以cookie形式,保存在了客户端的内存当中,这个时候我
们可以通过url重写,来保证session的有效性.
重写url的方法如下
resp.encodeURL(request.getRequestURL().toString());
解决:
1.javascript阻止表单重复提交
<script type="text/javascript">
var iscommitted =false;//记录表单是否提交,2.设置按钮
不可用
function dosubmit(){
if(!iscommitted){
iscommitted =true;
return true;
}else{
return false;
}
}

</script>


2。服务器端防止表单重复提交


public class FormServlet extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
//产生随机数(表单号)
TokenProccessor tp =TokenProccessor.getInstance();
String token =tp.generateToken();
boolean b =isTokenValid(request);
if(!b){
System.out.println("不要重复提交");
return;
}
request.getSession().removeAttribute("token");
System.out.println("想数据库中提交注册。。。。");
}
//判斷表單是否提交
public boolean isTokenValid(HttpServletRequest request) {
String client_token = request.getParameter("token");
if (client_token == null) {
return false;
}
String server_token = (String) request.getSession
().getAttribute(
"token");
if (server_token == null) {
return false;
}
if (!server_token.equals(client_token)) {
return false;
}
return true;
}

public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {

}

static class TokenProccessor { // 令牌
/**
* 1.把构造方法私有 2.自己创建一个 3.对外暴露一个方
法,允许获取上面创建的对象
*/
private TokenProccessor() {
}

private static final TokenProccessor instance = new
TokenProccessor();

public static TokenProccessor getInstance() {
return instance;

}
//任意的二进制数据是三个字节 ,指纹128位字节
public String generateToken() {
String token = System.currentTimeMillis() +
new Random().nextInt()
+ "";
try {
MessageDigest md =
MessageDigest.getInstance("md5");
byte[] md5 = md.digest();
//上传下载用到base64
// base64編程:把三个字节变成四个字
节 ,编之后最大不会超过64
BASE64Encoder encoder = new
BASE64Encoder();
encoder.encode(md5);

} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
return null;

}
}
6.中兴供应商协同管理系统
1.主要做了报表开发,ireport报表画出来,(供应商,项目经理,面试通过率,人员到位率等等报表)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值