package hcxAction;

import hcxMode.Advertises;

import hcxMode.Areas;

import hcxMode.Saveresume;

import hcxService.AdvertisesService;

import hcxService.SaveresumeService;

import java.io.File;

import java.io.IOException;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpSession;

import org.apache.commons.io.FileUtils;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.bind.annotation.ResponseBody;

import org.springframework.web.multipart.MultipartFile;

import com.util.mail.MailSenderInfo;

import com.util.mail.SimpleMailSender;

/**

* @author cunli

*招聘

*/

@Controller

@RequestMapping("/advertisea")

public class AdvertiseAction {

@Autowired

private AdvertisesService advertisesService;

@Autowired

private SaveresumeService saveresumeService;

UsersAction usersAction=new UsersAction();

/**

* @param model

* @param request

* @return 发布成功

*/

@RequestMapping("/zhaopinissuesuccess")

public String zhaopinissuesuccess( Advertises advertises, Model model,HttpSession session) throws IOException {

advertises.setUserId(usersAction.uid(session));

// 根据userid查询最大的id

int maxid = advertisesService.advertiseidService(advertises);

advertises.setId(maxid);

model.addAttribute("zwid", maxid);

int success = advertisesService.updatexiangxiService(advertises);

if (success == 0) {

model.addAttribute("errormsg", "信息发布失败,请重试");

return "/operate/particulars";

}

return "/operate/issuesuccess";

}

/**

* @param model

* @param request

* @param position

* @return 填写详情

*/

@RequestMapping("/particulars")

public String particulars(Model model,HttpSession session,Advertises advertises) {

advertises.setUserId(usersAction.uid(session));

int ok = advertisesService.addmsgService(advertises);

if (ok == 0) {// faid

model.addAttribute("faidmsg", "添加数据失败  ## 你可以重试一次");

return "/navigations/issuepostion";

}

return "/operate/particulars";

}

/**

* 预览图片

*

* @param files

* @param model

* @param request

* @param response

* @return

* @throws IOException

*/

@RequestMapping("/instantuploadview")

public String instanupload(

@RequestParam(required = false) MultipartFile[] files, Model model,

HttpServletRequest request)

throws IOException {

String apurl = "";

for (MultipartFile file : files) {

if (file.isEmpty()) {

return "";

} else {

// 1.===============替换文件名 并copy上传图片(原图)===============

String fileName = file.getOriginalFilename();

String realPath = request.getSession().getServletContext()

.getRealPath("\\");// 项目磁盘路径

// 预览的文件名 userName.jpg xxx.jpg ---nametime.jpg(利用时间戳解决浏览器图片缓存问题)

String randomm = String.valueOf(Math.random() * 10);

String viewplc = fileName.replace(

fileName.substring(0, fileName.lastIndexOf(".")),

randomm + System.currentTimeMillis());

// 保存 的文件名uuid.jpg

String saveplc = fileName.replace(

fileName.substring(0, fileName.lastIndexOf(".")),

randomm + System.currentTimeMillis());

// 项目磁盘绝对路径---->图片读取路径

String viewPath = realPath + "images" + "\\companyphoto\\"

+ viewplc;

// 项目磁盘绝对路径

String savePath = realPath + "images" + "\\companyphoto\\"

+ saveplc;

FileUtils.copyInputStreamToFile(file.getInputStream(),

new File(viewPath));

System.out.println("**************图片磁盘绝对路径**********  "

+ savePath);

// 预览路径

apurl = "/images/companyphoto/" + viewplc;

request.getSession().setAttribute("apurl", apurl);

model.addAttribute("apurl", apurl);

System.out.println("上传图片预览路径====:" + apurl);

// 数据库保存路径

String saveURL = "/images/companyphoto/" + saveplc;

request.getSession().setAttribute("savePath", savePath);

request.getSession().setAttribute("saveURL", saveURL);

}

}

return "/operate/particulars";

}

/**

* 信息列表

*/

@RequestMapping("/listmsg")

public String listmsg(Model model, String ps,String area,HttpSession session) {

Advertises advertises = new Advertises();

if (area!=null) {

String va =null;

try {

va = new String(area.getBytes("iso-8859-1"), "utf-8");

advertises.setOfficearea(va);

System.out.println("**************************va"+va);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

if (ps!=null) {

session.setAttribute("ps", ps);

}

String position = "";

try {

String psn = new String((session.getAttribute("ps").toString()).getBytes("iso-8859-1"), "utf-8");

model.addAttribute("psn", psn);

String vv=psn.substring(0, 2);

position ="%"+ vv+"%";

} catch (Exception e) {

e.printStackTrace();

}

//                model.addAttribute("psn", ps);

//                String vv=ps.substring(0, 2);

//                position ="%"+ vv+"%";

advertises.setPosition(position);

advertises.setId(0);

List<Advertises> alladvertises = advertisesService

.alladvertisesService(advertises);

model.addAttribute("alladvertises", alladvertises);

model.addAttribute("page", 30);

return "/operate/listmsg";

}

/**

* 显示更多信息

*/

@RequestMapping("/listmsgmore")

public @ResponseBody

List<Advertises> listmsgmore(String psn, int page) {

String position ="%"+ psn.substring(0, 2)+"%";

Advertises advertises = new Advertises();

advertises.setPosition(position);

advertises.setId(page);

List<Advertises> alladvertises = advertisesService

.alladvertisesService(advertises);

return alladvertises;

}

/**

* @param id

* @param model

* @param request

* @return 详细的招聘信息页面

*/

@RequestMapping("companymsg")

public String companymsg(int id,Model model) {

Advertises advertises=new Advertises();

advertises.setId(id);

advertises = advertisesService.admsgService(advertises);

model.addAttribute("advertises", advertises);

advertises.setSeveraltimes(advertises.getSeveraltimes()+1);

int up=advertisesService.updateseveraltiemsService(advertises);

if (up>0) {

System.out.println("*********浏览次数更新成功***************");

} else {

System.out.println("***浏览次数******未更新***************");

}

return "/operate/companymsg";

}

/**

* @param id

* @return 去 修改信息

*/

@RequestMapping("/updateadvmsg")

public String updateadvmsg(int id,Model model){

model.addAttribute("id", id);

return "/usermsg/updateadvmsg";

}

/**

* @param advertises

* @param request

* @param model

* @return 正在 修改信息

*/

@RequestMapping("/updateadv")

public String updateadv(Advertises advertises,HttpSession session,Model model){

advertises.setUserId(usersAction.uid(session));

advertises.setId(advertises.getId());

int success = advertisesService.updatexiangxiService(advertises);

if (success>0) {

return "redirect:/usersa/informationone.html";

}

model.addAttribute("errmsg", true);

return "/usermsg/updateadvmsg";

}

/**

* @param advertises

* @param request

* @param model

* @return 删除信息

*/

@RequestMapping("/deladvmsg")

public String deladvmsg(Advertises advertises,HttpSession session,Model model){

advertises.setId(advertises.getId());

int del=advertisesService.delmsgService(advertises);

if (del==0) {

model.addAttribute("errmsg", true);

}

advertises.setUserId(usersAction.uid(session));

List<Advertises> listad = advertisesService.listadvService(advertises);

model.addAttribute("listad", listad);

return "/usermsg/informationone";

}

/**

* @param advertises

* @param request

* @param model

* @return 全部删除

*/

@RequestMapping("/deltelmsg")

public String deltelmsg(Advertises advertises,HttpSession session,Model model,String selectid){

String[] one=selectid.split(",");

for (String id : one) {

advertises.setId(Integer.parseInt(id));

int del=advertisesService.delmsgService(advertises);

if (del>0) {

System.out.println("***********删除成功**************");

} else {

System.out.println("***********删除失败**************");

}

}

advertises.setUserId(usersAction.uid(session));

List<Advertises> listad = advertisesService.listadvService(advertises);

model.addAttribute("listad", listad);

return "/usermsg/informationone";

}

/**

* @return 申请职位

*/

@SuppressWarnings("static-access")

@RequestMapping("/indicatetheposition")

public @ResponseBody String indicatetheposition(HttpSession session,String companyemail){

try {

int id=usersAction.uid(session);

try {

Saveresume saveresume=new Saveresume();

saveresume.setUserid(id);

saveresume=saveresumeService.saveresumesService(saveresume);

System.out.println(saveresume.getId());

try {

/* 发送邮件 */

MailSenderInfo mailInfo = new MailSenderInfo();

mailInfo.setMailServerHost("smtp.163.com");

mailInfo.setMailServerPort("25");

mailInfo.setValidate(true);

mailInfo.setUserName("13336017350@163.com");

mailInfo.setPassword("13336017350");// 您的邮箱密码

mailInfo.setFromAddress("13336017350@163.com");

mailInfo.setToAddress(companyemail);//发送给用户

mailInfo.setSubject("简历");

String mailcontent="<div style='margin-left:30px;font-family:'楷体';font-size:20px;font-weight:bold; '><div style='font-size:32px;padding-top:30px;padding-left:200px; padding-bottom:30px;font-weight:bold;'>简历</div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right; '>标题:</div><div style='float:left;'>"+saveresume.getJbiaoti()+"</div></div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right;'>姓名:</div><div style='float:left;'>"+saveresume.getJname()+"&nbsp;&nbsp;&nbsp;&nbsp;性别:"+saveresume.getJsex()+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;出生日期:"+saveresume.getJbirthday()+"</div></div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right;'>电话/手机:</div><div style='float:left;'>"+saveresume.getJphone()+"</div></div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right;'>工作年限:</div><div style='float:left;'>"+saveresume.getJworker()+"</div></div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right;'>学&nbsp;&nbsp;历:</div><div style='float:left;'>"+saveresume.getJschool()+"</div></div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right;'>期望工作区域:</div><div style='float:left;'>"+saveresume.getJarea()+"</div></div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right;'>期望月薪:</div><div style='float:left;'>"+saveresume.getJmoney()+"</div></div><div style='padding-bottom:40px;'><div style='float:left; width:180px;text-align:right;'>&nbsp;自我描述:</div><div style='float:left;width:500px;margin-bottom:50px;'>"+saveresume.getJdiscribe()+"</div></div></div>";

mailInfo.setContent(mailcontent);

// 这个类主要来发送邮件

SimpleMailSender sms = new SimpleMailSender();

sms.sendHtmlMail(mailInfo);// 发送html格式

} catch (Exception e) {

return "发送遇到问题了,请重试一次";

}

} catch (Exception e) {

return "写简历";

}

} catch (Exception e) {

return "请登录";

}

return "恭喜你,申请成功!";

}

}

Html5 upload img

2012年12月27日

20:36

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-">

<title>html 图片上传预览</title>

<script src="jquery/jquery-1.8.2.min.js" type="text/javascript"></script>

<script type="text/javascript">

$(function(){

$("input[type='file']").change(function(evt){

var files = evt.target.files;

for (var i =0 , f; f = files[i]; i++) {

if (!f.type.match('image.*')) {

continue;

}

var reader = new FileReader();

reader.onload = (function(theFile) {

return function(e) {

$("#list img").attr("src",e.target.result);  //预览图片的位置

};

})(f);

reader.readAsDataURL(f);

}

});

})

</script>

</head>

<body>

<form enctype="multipart/form-data" action="" method="post">

<input type="file" name="imageUpload" />

<div id="list"><img src=""></div>

</form>

</body>

</html>

select area from areas where cityid=(select cityid from cities where city like '杭州%') and id!=(select min(id) from areas where cityid=(select cityid from cities where city like '杭州%'));

select area from areas where cityid=(select cityid from cities where id=(select min(id) from cities where  provinceid=(select provinceid from provinces where province like '上海%')));

2013年1月3日

15:40

<link rel="stylesheet" href="/css/index.css"/>

<div class="body">

<hr />

<form id="ser" name="ser" method="post" action="$!{base}/usersa/ser.html">

<!--搜索框-->

<div class="soushuo">

<div class="lf">

<input name="goodsname" id="ss" type="text" value="会查询一下" onfocus="javascript:if(this.value == '会查询一下'){this.value = ''; this.style.color='#000000';}else{this.style.color='#000000';}" onblur="if(this.value==''){this.value='会查询一下';this.style.color='#A1A1A1';}else{this.style.color='#000000';}"/>

</div>

<div class="ri">

<input type="submit" name="soubtn" id="soubtn" value="搜 索" />

</div>

</div><div style="height:20px;"></div>

<!--搜索框 end-->

</form>

<div id="window">

<ul id="slideshow">

<li><img src="/images/1.png" width="1000px" height="250px" /></li>

<li><img src="/images/2.png" width="1000px" height="250px"/></li>

<li><img src="/images/3.png" width="1000px" height="250px" /></li>

</ul>

</div>

<div class="con">

<ul>

<li><img src="/images/huichaxun.png"/></li>

<li><a href="/huitaobao/index.htm" title="会淘宝"><img src="/images/huitaobao.png"/></a></li>

<li><img src="/images/usermsg/sjmp.png" id="sjmp"/></li>

<li> <img src="/images/love.png"/></li>

<li><a href="http://baidu.lehecai.com/lottery/draw/?agentId=5555" title="彩票中奖"><img src="/images/winningthelottery.png"/></a></li>

<div class="clearBoth"></div>

<li><a href="$!{base}/bigcompanya/postion.html" title="招聘信息"><img src="/images/postion.png"/></a> </li>

<li><a href="$!{base}/zhaoshanga/merchantsjion.html" title="招商加盟"><img src="/images/merchantsjion.png"/></a></li>

<li><a href="$!{base}/entertainmenta/entertainment.html" title="休闲娱乐"><img src="/images/entertainment.png"/></a></li>

<li><a href="$!{base}/housekeepinga/housekeeping.html" title="家政服务"><img src="/images/housekeeping.png"/></a></li>

<li ><a href="http://www.hzti.com/service/qry/peccancy.aspx?type=2&node=248" title="交通违章"><img src="/images/traffic.png"/></a></li>

<div class="clearBoth"></div>

<li><a href="$!{base}/bigshangpua/house.html" title="房产商铺"><img src="/images/housingshops.png"/></a></li>

<li><a href="$!{base}/bigdecorativea/decorative.html" title="装饰设计"><img src="/images/decorative.png"/></a></li>

<li><a href="$!{base}/traveholidaysa/travelholidays.html" title="度假旅游"><img src="/images/travelholidays.png"/></a></li>

<li><a href="$!{base}/carsdrivea/carsdrive.html" title="汽车自驾"><img src="/images/carsdrive.png"/></a></li>

<li ><a href="http://www.haha365.com" title="幽默笑话"><img src="/images/hehe.png"/></a></li>

</ul>

</div>

<div class="modetowimgwai">

<div class="zhongmeidiv"><a href="http://www.聚富装饰.com" title="聚富装饰"><img src="/images/usermsg/jfzs.jpg"/></a></div>

<div class="jichneg"><img src="/images/usermsg/hjmy.jpg" title="会玖贸易"/></div>

</div>

<br />

<div class="con">

<ul>

<li><a href="$!{base}/hotelsa/hotels.html" title="酒店宾馆"><img src="/images/hotels.png"/></a></li>

<li><a href="$!{base}/fooda/foodservice.html" title="餐饮美食"><img src="/images/foodservice.png"/></a></li>

<li><img src="/images/ithangye.png"/></li>

<li><a href="$!{base}/commerciala/shangwu.html" title="商务服务"><img src="/images/shangwuservier.png"/></a></li>

<li><a href="http://www.qunar.com"><img src="/images/ticketfare.png"/></a> </li>

<div class="clearBoth"></div>

<li><a href="$!{base}/furniturea/jiaju.html" title="家具家电"><img src="/images/Furnitureappliances.png"/></a></li>

<li><a href="$!{base}/builda/jiancai.html" title="建材装饰"><img src="/images/jiancai.png"/></a></li>

<li><a href="$!{base}/healtha/jianshen.html" title="健身养生"><img src="/images/jianshenyangsheng.png"/></a></li>

<li><a href="$!{base}/medicala/yiliaobaojian.html" title="医疗保健"><img src="/images/yiliaobaojian.png"/></a></li>

<li><a href="http://map.sogou.com/" title="中国地图"><img src="/images/chinamap.png"/></a> </li>

<div class="clearBoth"></div>

<li><a href="$!{base}/cosmetologya/meirong.html" title="美容美发"><img src="/images/meirongmeifa.png"/></a></li>

<li><a href="$!{base}/weddinga/hunqingliyi.html" title="婚庆礼仪"><img src="/images/hunqingliyi.png"/></a></li>

<li><a href="$!{base}/educationa/jiaoyupeixun.html" title="教育培训"><img src="/images/jiaoyupeixun.png"/></a></li>

<li><a href="$!{base}/abroada/chuguo.html" title="出国留学"><img src="/images/chuguoliuxue.png"/></a></li>

<li><a href="http://www.zh5000.com/" title="中国历史"><img src="/images/chinashistory.png"/></a></li>

<div class="clearBoth"></div>

<li><a href="$!{base}/supplya/gongying.html" title="供应需求"><img src="/images/gongyingxuqiu.png"/></a></li>

<li><a href="$!{base}/logisticsa/wuliuhuoyun.html" title="物流货运"><img src="/images/wuliuhuoyun.png"/></a></li>

<li><a href="$!{base}/collecta/mingqisc.html" title="名器收藏"><img src="/images/mingqi.png"/></a></li>

<li><a href="$!{base}/peta/petsland.html" title="爱宠世界"><img src="/images/petsland.png"/></a></li>

<li><a href="http://www.xingzuowu.com/" title="星座鸿运"><img src="/images/xingzuo.png"/></a></li>

<div class="clearBoth"></div>

<li><img src="/images/nullimg.png"/> </li>

<li><img src="/images/nullimg.png"/> </li>

<li><img src="/images/nullimg.png"/> </li>

<li><img src="/images/nullimg.png"/> </li>

<li><a href="http://www.ip138.com/ems/" title="快递查询"><img src="/images/kuaidi.png"/></a></li><div class="clear"></div>

</ul>

</div>

<div style="height:110px;"></div>

</div>

<!--主体 end-->

<script type="text/javascript" src="/jquery/jquery-latest.js"></script>

<script type="text/javascript" src="/jquery/jquery.timer.js" ></script>

<script type="text/javascript" src="/jquery/image-rotator.js"></script>

<script type="text/javascript" src="/jquery/jquery.easing.1.3.js"></script>

<script type="text/javascript" src="/js/index.js"></script>

201314 index.vm

2013年1月4日

16:12

<link  rel="stylesheet" href="/css/index.css"/>

<link  rel="stylesheet" href="/css/slider/nivo-slider.css"  type="text/css" media="screen" />

<div  class="body">

<hr />

<form id="ser"  name="ser" method="post"  action="$!{base}/usersa/ser.html">

<!--搜索框-->

<div class="soushuo">

<div class="lf">

<input  name="goodsname" id="ss" type="text"  value="会查询一下"  onfocus="javascript:if(this.value == '会查询一下'){this.value  = ''; this.style.color='#000000';}else{this.style.color='#000000';}"  onblur="if(this.value==''){this.value='会查询一下';this.style.color='#A1A1A1';}else{this.style.color='#000000';}"/>

</div>

<div class="ri">

<input  type="submit" name="soubtn" id="soubtn"  value="搜 索" />

</div>

</div><div  style="height:20px;"></div>

<!--搜索框 end-->

</form>

<div class="slider-wrapper  theme-default">

<div id="slider"  class="nivoSlider">

<img  src="/images/slider/1.png"  data-thumb="/images/slider/1.png" alt="" />

<img  src="/images/slider/2.png"  data-thumb="/images/slider/2.png" alt=""  />

<img  src="/images/slider/3.png"  data-thumb="/images/slider/3.png" alt=""  data-transition="slideInLeft" />

<img  src="/images/slider/1.png" data-thumb="images/1.png"  alt="" />

</div>

</div>

<div class="con">

<ul>

<li><img  src="/images/huichaxun.png"/></li>

<li><a  href="/huitaobao/index.htm" title="会淘宝"><img  src="/images/huitaobao.png"/></a></li>

<li><img  src="/images/usermsg/sjmp.png" id="sjmp"/></li>

<li> <img  src="/images/love.png"/></li>

<li><a  href="http://baidu.lehecai.com/lottery/draw/?agentId=5555"  title="彩票中奖"><img  src="/images/winningthelottery.png"/></a></li>

<div  class="clearBoth"></div>

<li><a  href="$!{base}/bigcompanya/postion.html" title="招聘信息"><img  src="/images/postion.png"/></a> </li>

<li><a  href="$!{base}/zhaoshanga/merchantsjion.html" title="招商加盟"><img  src="/images/merchantsjion.png"/></a></li>

<li><a  href="$!{base}/entertainmenta/entertainment.html" title="休闲娱乐"><img  src="/images/entertainment.png"/></a></li>

<li><a  href="$!{base}/housekeepinga/housekeeping.html" title="家政服务"><img  src="/images/housekeeping.png"/></a></li>

<li ><a  href="http://www.hzti.com/service/qry/peccancy.aspx?type=2&node=248"  title="交通违章"><img  src="/images/traffic.png"/></a></li>

<div  class="clearBoth"></div>

<li><a  href="$!{base}/bigshangpua/house.html" title="房产商铺"><img  src="/images/housingshops.png"/></a></li>

<li><a  href="$!{base}/bigdecorativea/decorative.html" title="装饰设计"><img  src="/images/decorative.png"/></a></li>

<li><a  href="$!{base}/traveholidaysa/travelholidays.html" title="度假旅游"><img  src="/images/travelholidays.png"/></a></li>

<li><a  href="$!{base}/carsdrivea/carsdrive.html" title="汽车自驾"><img  src="/images/carsdrive.png"/></a></li>

<li ><a  href="http://www.haha365.com" title="幽默笑话"><img  src="/images/hehe.png"/></a></li>

</ul>

</div>

<div class="modetowimgwai">

<div  class="zhongmeidiv">

<a  href="http://www.聚富装饰.com" title="聚富装饰"><img  src="/images/usermsg/jfzs.jpg"/></a>

</div>

<div  class="jichneg"><img src="/images/usermsg/hjmy.jpg"  title="会玖贸易"/></div>

</div>

<br />

<div class="con">

<ul>

<li><a  href="$!{base}/hotelsa/hotels.html" title="酒店宾馆"><img  src="/images/hotels.png"/></a></li>

<li><a  href="$!{base}/fooda/foodservice.html" title="餐饮美食"><img  src="/images/foodservice.png"/></a></li>

<li><img  src="/images/ithangye.png"/></li>

<li><a  href="$!{base}/commerciala/shangwu.html" title="商务服务"><img  src="/images/shangwuservier.png"/></a></li>

<li><a  href="http://www.qunar.com"><img  src="/images/ticketfare.png"/></a> </li>

<div  class="clearBoth"></div>

<li><a  href="$!{base}/furniturea/jiaju.html" title="家具家电"><img  src="/images/Furnitureappliances.png"/></a></li>

<li><a  href="$!{base}/builda/jiancai.html" title="建材装饰"><img  src="/images/jiancai.png"/></a></li>

<li><a  href="$!{base}/healtha/jianshen.html" title="健身养生"><img  src="/images/jianshenyangsheng.png"/></a></li>

<li><a  href="$!{base}/medicala/yiliaobaojian.html" title="医疗保健"><img  src="/images/yiliaobaojian.png"/></a></li>

<li><a  href="http://map.sogou.com/" title="中国地图"><img  src="/images/chinamap.png"/></a> </li>

<div  class="clearBoth"></div>

<li><a  href="$!{base}/cosmetologya/meirong.html" title="美容美发"><img  src="/images/meirongmeifa.png"/></a></li>

<li><a  href="$!{base}/weddinga/hunqingliyi.html" title="婚庆礼仪"><img  src="/images/hunqingliyi.png"/></a></li>

<li><a  href="$!{base}/educationa/jiaoyupeixun.html" title="教育培训"><img  src="/images/jiaoyupeixun.png"/></a></li>

<li><a  href="$!{base}/abroada/chuguo.html" title="出国留学"><img  src="/images/chuguoliuxue.png"/></a></li>

<li><a  href="http://www.zh5000.com/" title="中国历史"><img  src="/images/chinashistory.png"/></a></li>

<div  class="clearBoth"></div>

<li><a  href="$!{base}/supplya/gongying.html" title="供应需求"><img  src="/images/gongyingxuqiu.png"/></a></li>

<li><a  href="$!{base}/logisticsa/wuliuhuoyun.html" title="物流货运"><img  src="/images/wuliuhuoyun.png"/></a></li>

<li><a  href="$!{base}/collecta/mingqisc.html" title="名器收藏"><img  src="/images/mingqi.png"/></a></li>

<li><a  href="$!{base}/peta/petsland.html" title="爱宠世界"><img  src="/images/petsland.png"/></a></li>

<li><a  href="http://www.xingzuowu.com/" title="星座鸿运"><img  src="/images/xingzuo.png"/></a></li>

<div  class="clearBoth"></div>

<li><img  src="/images/nullimg.png"/> </li>

<li><img  src="/images/nullimg.png"/> </li>

<li><img  src="/images/nullimg.png"/> </li>

<li><img  src="/images/nullimg.png"/> </li>

<li><a  href="http://www.ip138.com/ems/" title="快递查询"><img  src="/images/kuaidi.png"/></a></li><div   class="clear"></div>

</ul>

</div>

<div  style="height:110px;"></div>

</div>

<!--主体 end-->

<script  type="text/javascript"  src="/jquery/jquery-latest.js"></script>

<script  type="text/javascript" src="/jquery/jquery.timer.js"  ></script>

<script  type="text/javascript"  src="/jquery/image-rotator.js"></script>

<script  type="text/javascript"  src="/jquery/jquery.easing.1.3.js"></script>

<script  type="text/javascript"  src="/js/index.js"></script>

<script  type="text/javascript"  src="/jquery/jquery.nivo.slider.js"></script>

<script  type="text/javascript">

$(window).load(function() {

$('#slider').nivoSlider();

});

</script>

清江路173号 总管塘 车站

Retrofit

2016年5月13日

23:28

testCompile'junit:junit:4.12'

compile'com.android.support:appcompat-v7:23.4.0'

compile'com.android.support:design:23.4.0'

compile'com.android.support:support-annotations:23.4.0'

compile'com.intellij:annotations:12.0'

compile'com.squareup.retrofit2:converter-gson:2.0.0-beta4'

compile'com.squareup.okhttp3:okhttp:(insertlatestversion)'

compile'com.squareup.retrofit2:retrofit:(insertlatestversion)'

Retrofit

A type-safe HTTP client for Android and Java

Introduction

Retrofit turns your HTTP API into a Java interface.

public interface GitHubService {
   @GET("users/{user}/repos")
   Call<List<Repo>> listRepos(@Path("user") String user);
 }

The Retrofit class generates an implementation of the GitHubService interface.

Retrofit retrofit = new Retrofit.Builder()
     .baseUrl("https://api.github.com/")
     .build();

GitHubService service = retrofit.create(GitHubService.class);

Each Call from the created GitHubService can make a synchronous or asynchronous HTTP request to the remote webserver.

Call<List<Repo>> repos = service.listRepos("octocat");

Use annotations to describe the HTTP request:

      • URL parameter      replacement and query parameter support
      • Object conversion      to request body (e.g., JSON, protocol buffers)
      • Multipart request      body and file upload

Note: This site is still in the process of being expanded for the new 2.0 APIs.

API Declaration

Annotations on the interface methods and its parameters indicate how a request will be handled.

REQUEST METHOD

Every method must have an HTTP annotation that provides the request method and relative URL. There are five built-in annotations: GET, POST, PUT, DELETE, and HEAD. The relative URL of the resource is specified in the annotation.

@GET("users/list")

You can also specify query parameters in the URL.

@GET("users/list?sort=desc")

URL MANIPULATION

A request URL can be updated dynamically using replacement blocks and parameters on the method. A replacement block is an alphanumeric string surrounded by { and }. A corresponding parameter must be annotated with @Path using the same string.

@GET("group/{id}/users")
 Call<List<User>> groupList(@Path("id") int groupId);

Query parameters can also be added.

@GET("group/{id}/users")
 Call<List<User>> groupList(@Path("id") int groupId, @Query("sort") String sort);

For complex query parameter combinations a Map can be used.

@GET("group/{id}/users")
 Call<List<User>> groupList(@Path("id") int groupId, @QueryMap Map<String, String> options);

REQUEST BODY

An object can be specified for use as an HTTP request body with the @Body annotation.

@POST("users/new")
 Call<User> createUser(@Body User user);

The object will also be converted using a converter specified on the Retrofit instance. If no converter is added, only RequestBodycan be used.

FORM ENCODED AND MULTIPART

Methods can also be declared to send form-encoded and multipart data.

Form-encoded data is sent when @FormUrlEncoded is present on the method. Each key-value pair is annotated with @Fieldcontaining the name and the object providing the value.

@FormUrlEncoded
 @POST("user/edit")
 Call<User> updateUser(@Field("first_name") String first, @Field("last_name") String last);

Multipart requests are used when @Multipart is present on the method. Parts are declared using the @Part annotation.

@Multipart
 @PUT("user/photo")
 Call<User> updateUser(@Part("photo") RequestBody photo, @Part("description") RequestBody description);

Multipart parts use one of Retrofit's converters or they can implement RequestBody to handle their own serialization.

HEADER MANIPULATION

You can set static headers for a method using the @Headers annotation.

@Headers("Cache-Control: max-age=640000")
 @GET("widget/list")
 Call<List<Widget>> widgetList();

@Headers({
     "Accept: application/vnd.github.v3.full+json",
     "User-Agent: Retrofit-Sample-App"
 })
 @GET("users/{username}")
 Call<User> getUser(@Path("username") String username);

Note that headers do not overwrite each other. All headers with the same name will be included in the request.

A request Header can be updated dynamically using the @Header annotation. A corresponding parameter must be provided to the@Header. If the value is null, the header will be omitted. Otherwise, toString will be called on the value, and the result used.

@GET("user")
 Call<User> getUser(@Header("Authorization") String authorization)

Headers that need to be added to every request can be specified using an OkHttp interceptor.

SYNCHRONOUS VS. ASYNCHRONOUS

Call instances can be executed either synchronously or asynchronously. Each instance can only be used once, but callingclone() will create a new instance that can be used.

On Android, callbacks will be executed on the main thread. On the JVM, callbacks will happen on the same thread that executed the HTTP request.

Retrofit Configuration

Retrofit is the class through which your API interfaces are turned into callable objects. By default, Retrofit will give you sane defaults for your platform but it allows for customization.

CONVERTERS

By default, Retrofit can only deserialize HTTP bodies into OkHttp's ResponseBody type and it can only accept its RequestBody type for @Body.

Converters can be added to support other types. Six sibling modules adapt popular serialization libraries for your convenience.

      • Gson: com.squareup.retrofit2:converter-gson
      • Jackson: com.squareup.retrofit2:converter-jackson
      • Moshi: com.squareup.retrofit2:converter-moshi
      • Protobuf: com.squareup.retrofit2:converter-protobuf
      • Wire: com.squareup.retrofit2:converter-wire
      • Simple XML: com.squareup.retrofit2:converter-simplexml
      • Scalars      (primitives, boxed, and String): com.squareup.retrofit2:converter-scalars

Here's an example of using the GsonConverterFactory class to generate an implementation of the GitHubService interface which uses Gson for its deserialization.

Retrofit retrofit = new Retrofit.Builder()
     .baseUrl("https://api.github.com")
     .addConverterFactory(GsonConverterFactory.create())
     .build();

GitHubService service = retrofit.create(GitHubService.class);

CUSTOM CONVERTERS

If you need to communicate with an API that uses a content-format that Retrofit does not support out of the box (e.g. YAML, txt, custom format) or you wish to use a different library to implement an existing format, you can easily create your own converter. Create a class that extends the Converter.Factory class and pass in an instance when building your adapter.

Download

↓ Latest JAR

The source code to the Retrofit, its samples, and this website is available on GitHub.

MAVEN

<dependency>
   <groupId>com.squareup.retrofit2</groupId>
   <artifactId>retrofit</artifactId>
   <version>(insert latest version)</version>
 </dependency>

GRADLE

compile 'com.squareup.retrofit2:retrofit:(insert latest version)'

Retrofit requires at minimum Java 7 or Android 2.3.

PROGUARD

If you are using Proguard in your project add the following lines to your configuration:

-dontwarn retrofit2.**
 -keep class retrofit2.** { *; }
 -keepattributes Signature
 -keepattributes Exceptions

Contributing

If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code compiles by running mvn clean verify.

Before your code can be accepted into the project you must also sign the Individual Contributor License Agreement (CLA).

License

Copyright 2013 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

来自 <http://square.github.io/retrofit/#api-declaration>

2016年5月14日

0:03

log4j2.xmllog4j-api-2.5.jarlog4j-core-2.5.jar

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xml>

<Configuration status="WARN">

<Appenders>

<Console name="Console" target="SYSTEM_OUT">

<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5level %logger{36} - %msg%n"/>

</Console>

<File name="log" fileName="logs.log" append="false">

<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>

</File>

</Appenders>

<Loggers>

<Logger name="com.dbyl.libarary.utils.Log" level="all">

<AppenderRef ref="Console"/>

<AppenderRef ref="log"/>

</Logger>

<Root level="trace">

<AppenderRef ref="Console"/>

<AppenderRef ref="log"/>

</Root>

</Loggers>

</Configuration>

@WebServlet(urlPatterns = "/HomeServlet",asyncSupported=true)

public class HomeServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

private static final Logger LOGGER = LogManager.getLogger(HomeServlet.class);

public static void main(String[] args) {

LOGGER.info("--------------info------------------"+HomeServlet.class);

}

public void testLog() {

LOGGER.trace("Trace Message!");

LOGGER.debug("Debug Message!");

LOGGER.info("Info Message!");

LOGGER.warn("Warn Message!");

LOGGER.error("Error Message!");

LOGGER.fatal("Fatal Message!");

LOGGER.info("--------------info------------------"+HomeServlet.class.getName());

LOGGER.info("--------------info------------------"+HomeServlet.class);

LOGGER.debug("------------debug--------------------");

LOGGER.fatal("---------------fatal-----------------");

LOGGER.info("--------------------------------");

getLogger(Bar.class.getName())

getLogger(MyAPP.class) //官方推荐的写法

getLogger("HomeServlet")

getLogger()

public class MyService {

// instead of Logger logger = LogManager.getLogger(MyService.class):

private static final ExtLogger logger = ExtLogger.create(MyService.class);

public void demoExtendedLogger() {

// ...

logger.trace("the built-in TRACE level");

logger.verbose("a custom level: a VERBOSE message");

logger.debug("the built-in DEBUG level");

logger.notice("a custom level: a NOTICE message");

logger.info("the built-in INFO level");

logger.diag("a custom level: a DIAG message");

logger.warn("the built-in WARN level");

logger.error("the built-in ERROR level");

logger.fatal("the built-in FATAL level");

logger.notice("java 8 lambda expression only executed if NOTICE is enabled: {}", () -> someMethod());

// ...

}

...

}

17.1.7 Generating Extende

el 表达式

2016年5月14日

0:03

表示变量的作用域,一共4种。pageScope: 表示变量只能在本页面使用。requestScope:表示变量能在本次请求中使用。sessionScope:表示变量能在本次会话中使用。applicationScope:表示变量能在整个应用程序中使用。

requestScope

应该用 requestScope.empList  获取对象还是直接获取对象?

escapeXml="true" el 表达式

在<c:out>标签中有一个escapeXml属性,其默认值为true,意思是是否过滤为xml文档。

如果为escapeXml="false",则 将其中的html、xml解析出来。如value="<font size=16>java</font>",会显示为大小为16的”java“

如果为escapeXml="true",则显示<font size=16>java</font>

在<c:out>中,escapeXML属性默认为true。

当设置escapeXML的属性为true时,将value中的值以字符串的形式原封不动的显示出来。

如果要让内容中的hmtl标签以HTML格式显示,就将escapeXML属性值为false 即可

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

2016年5月14日

0:03

<c:out value='${param.emailAddress}'/>

<c:if test='${not empty param.emailAddress}'>...</c:if>

<jstl:action value='${expr}'/>

<jstl:action value='text'/>

<jstl:action value='${expr}text${expr}${expr}more text${expr}'/>

Examine the JSTL expression language in detail, starting with expressions and identifiers, and ending with sections on using the expression language for custom action attributes and common mistakes that developers make when using the expression language.

This chapter is from the book 

This chapter is from the book

Core JSTL: Mastering the JSP Standard Tag Library

Learn More Buy

This chapter is from the book

Core JSTL: Mastering the JSP Standard Tag Library

Learn More Buy

Topics in This Chapter

  • Expression Language Overview
  • Expressions
  • Identifiers
  • Operators
  • Type Coercion
  • Literal Values
  • Implicit Objects
  • Method Invocation
  • EL Expressions in Custom Actions
  • Common Mistakes

2.1 Expression Language Overview

Although JSTL, as its name implies, provides a set of standard tags, its single most important feature may well be the expression language it defines. That expression language greatly reduces the need for specifying tag attribute values with Java code and significantly simplifies accessing all sorts of application data, including beans, arrays, lists, maps, cookies, request parameters and headers, context initialization parameters, and so on. In fact, the JSTL expression language adds so much value to JSP that it will be incorporated into JSP 2.0.1

This chapter examines the JSTL expression language in detail, starting with expressions and identifiers and ending with sections on using the expression language for custom action attributes and common mistakes that developers make when using the expression language.

NOTE

To illustrate the JSTL expression language, this chapter uses a number of JSTL actions, such as <c:out>, <c:if>, and <c:forEach>, that have not yet been formally discussed in this book. However, the use of those actions is intuitive and this chapter does not use any of those action's advanced features. See Chapter 3, "General-Purpose and Conditional Actions," and "Iteration Actions" on page 150 for formal discussions of the actions used throughout this chapter.

2.1 Expression Language Overview

The JSTL expression language is a simple language inspired by ECMAScript (also known as JavaScript) and XPath. The expression language provides:

  • Expressions and identifiers
  • Arithmetic, logical, and relational operators
  • Automatic type coercion
  • Access to beans, arrays, lists, and maps
  • Access to a set of implicit objects and servlet properties

All of the features listed above are described in this chapter.

Throughout this book, for convenience the expression language is referred to with the acronym EL and JSTL expressions are referred to as EL expressions.

How the Expression Language Works

Nearly all of the JSTL actions have one or more dynamic attributes that you can specify with an EL expression;2 for example, you can specify a request parameter with the <c:out> action's value attribute like this:

<c:out value='${param.emailAddress}'/>

The preceding expression displays the value of a request parameter named emailAddress. You can also use EL expressions to perform conditional tests, for example:

<c:if test='${not empty param.emailAddress}'>...</c:if>

The body of the preceding <c:if> action is evaluated if the emailAddress request parameter is not empty, meaning neither null nor an empty string.

If you're using JSTL with JSP 1.2, you can only use JSTL expressions to specify values for JSTL action attributes, as illustrated above.3 All JSTL actions that have dynamic attributes interpret EL expressions before they are passed to the action's tag handler, so the expression language is applied—and values are typically coerced—before the tag handler gets them.

How to Use the Expression Language

Attributes of JSTL actions can be specified with EL expressions in one of three ways. First, an attribute can be specified with a single expression like this:4

<jstl:action value='${expr}'/>

In the preceding code fragment, the expression ${expr} is evaluated and its value is coerced to the type expected by the value attribute.

Attribute values can also be specified as strings, like this:

<jstl:action value='text'/>

The string specified for the value attribute in the preceding code fragment is coerced to the type expected by that attribute.

Finally, attribute values can consist of one or more expressions intermixed with strings, like this:

<jstl:action value='${expr}text${expr}${expr}more text${expr}'/>

In the previous code fragment, each of the four expressions is evaluated in order from left to right, coerced to a string, and concatenated with the intermixed text. The resulting string is subsequently coerced to the value expected by the value attribute.

Page 1 of 10 Next >

  • + Share This
  • zonghe的更多相关文章

    1. SQL基本语句以及示例

      基本语句: /*dorp colunm*/ 语法:ALTER TABLE 表名   DROP COLUMN 要删除的字段 验证财务转换的正确性,查询以下两个表是否有数据 /*表连接inner jion ...

    2. VQ结合SVM分类方法

      今天整理资料时,发现了在学校时做的这个实验,当时整个过程过重偏向依赖分类器方面,而又很难对分类器性能进行一定程度的改良,所以最后没有选用这个方案,估计以后也不会接触这类机器学习的东西了,希望它对刚入门 ...

    3. 【OpenStack】OpenStack系列3之Swift详解

      Swift安装部署(与keystone依赖包有冲突,需要安装不同版本eventlet) 参考:http://www.server110.com/openstack/201402/6662.html h ...

    4. 循环中不要放入openSession()

      for(Shop s:list) { System.out.println(s.getName()); String sql="select shopId,sum(ele_bank+ele_ ...

    5. eclipse的使用

      类似于数据库系统的三层目录结构,一般而言IDE在逻辑上都有三层目录结构:工作空间(或解决方案) -> 工程 -> 文件. 当然,如果构建java project,那么目录结构是可以更深,因 ...

    6. title滚动

      代码: <html><head><title>滚动的文字在TITLE栏上不停滚动</title><script language=javascri ...

    7. 用于COB工艺的PCB设计指导

      绑定角度尽量在45°之内,多于这个角度,绑定时候,银线不好打入焊盘.而且打入焊盘的尾部可能短路到相邻的焊盘,绑定焊盘之间的间距一般在4MIL为极限,半场的工艺一般就这样了.而且焊盘离被绑定的IC引脚最 ...

    8. listview,fragment结合起来

      这是csdn上的以个demo,很适合初学者.来源:http://download.csdn.net/detail/endlife99/7274419,侵删. MainActiviy: package ...

    9. storm的并发

      1 storm并行的基本概念 storm集群中的一个机器可以运行一个或者多个worker,对应于一个或者多个topologies. 1个worker进程运行1个或多个excutor线程.每个worke ...

    随机推荐

    1. 持续集成Jenkins+sonarqube部署教程

      1 引言 1.1 文档概要 本文主要介绍jenkins,sonar的安装与集成,基于ant,maven构建.用一个例子介绍jenkins的编译打包部署,代码检查.最后集成jenkins.(现阶段只是简 ...

    2. 【NOIP2006提高组】能量项链

      说好的好好写人话的题解 嗯很多题解都说过这是一个石子合并的模型它也确实就是一个石子合并的模型.然而就算这样我也不会写最后仍然写了个记忆化搜索 首先我们不论环状,就直接一条链型,当只剩下两个珠子的时候, ...

    3. IntentService和Service的区别

      整个看下来是一个Service+Thread+handle的结合体, Service:比Activity的被kill的级别低 Thread:不阻塞UI线程 Handle:队列式的消息循环 那这个玩意的 ...

    4. MySQL千万级数据JDBC插入

      案例语句: String sql = "LOAD DATA LOCAL INFILE '" + dataFilepath + "' into table " + ...

    5. 定时发布任务,在global.asax中获取文件的物理路径的方法

      如果要把一个相对路径或者虚拟路径映射道服务器的物理路径,通常会使用Server.MapPath()函数,比如将根目录下的html目录映射为物理路径:Server.MapPath("html& ...

    6. SQLServer 重建索引前后对比

      在做维护项目的时,我们经常会遇到索引维护的问题,通过语句,我们就可以判断某个表的索引是否需要重建. 执行一下语句:先分析表的索引 分析表的索引建立情况:DBCC showcontig('Table') ...

    7. workerman简单例子

      workerman下载地址 http://www.workerman.net/ html <!DOCTYPE html> <html> <head> <tit ...

    8. WI-FI: connection through CLI

      First, ensure that the computer/sbc has WI-FI parts. install wpa_supplicant, edit /etc/wpa_supplican ...

    9. sql 针对多个id或名称的分割和组合

      开发中经常遇到把多个id拼接在一起符号隔开传入数据库,那拆分呢就是个大事 SELECT nPushID INTO #temp FROM Table1 ), nCoulmn) SELECT * FROM ...

    10. ssh 依赖关系

      安装ssh时: sudo apt-get install openssh-server 出现错误: 下列软件包有未满足的依赖关系: openssh-server : 依赖: openssh-clien ...