`
mosquito2a
  • 浏览: 3979 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
hiberateTool 生成对象
http://www.cnblogs.com/mingziday/p/4475124.html
plist 及 二维码生成
public class WriteXml {
	
	/**
	 * 
	 * @param xmlPath 
	 * @param ipaUrl
	 * @param picUrl
	 * @param ipaPackage
	 * @param ipaVersion
	 * @param ipaName
	 * @throws FileNotFoundException 
	 * @throws UnsupportedEncodingException 
	 */
	public static void writeXml(String xmlPath, String ipaUrl, 
			String picUrl, String ipaPackage, String ipaVersion, String ipaName) throws Exception {
	
		ipaUrl = ipaUrl == null ? "" : ipaUrl;
		picUrl = picUrl == null ? "" : picUrl;
		ipaPackage = ipaPackage == null ? "" : ipaPackage;
		ipaVersion = ipaVersion == null ? "" : ipaVersion;
		ipaName = ipaName == null ? "" : ipaName;
		
		Document document = DocumentHelper.createDocument();  
		document.setXMLEncoding("UTF-8");  
//		<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
		document.addDocType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd");
		
		Element root = document.addElement("plist"); 
		root.addAttribute("version", "1.0");
		
		 Element dictRoot = root.addElement("dict");
		 
		 Element key = dictRoot.addElement("key");
		 key.addText("items");
		 Element array = dictRoot.addElement("array");
		 
		 Element dict1 = array.addElement("dict");
		 
		 Element dictRootKey = dict1.addElement("key"); 
		 
		 dictRootKey.addText("assets");
		 
		 Element dict1Array = dict1.addElement("array");
		 
		 // array 里面的dict 信息
		 // ipa 下载地址
		 Element dict21 = dict1Array.addElement("dict");
		 dict21.addElement("key").addText("kind");
		 dict21.addElement("string").addText("software-package");
		 dict21.addElement("key").addText("url");
		 dict21.addElement("string").addText(ipaUrl);
		 
		 // ipa大小
		 Element dict22 = dict1Array.addElement("dict");
		 dict22.addElement("key").addText("kind");
		 dict22.addElement("string").addText("full-size-image");
		 dict22.addElement("key").addText("needs-shine");
		 dict22.addElement("true").addText("");
		 dict22.addElement("key").addText("url");
		 dict22.addElement("string").addText(picUrl);
		 
		 //ipa 图片
		 Element dict23 = dict1Array.addElement("dict");
		 dict23.addElement("key").addText("kind");
		 dict23.addElement("string").addText("display-image");
		 dict23.addElement("key").addText("needs-shine");
		 dict23.addElement("true").addText("");
		 dict23.addElement("key").addText("url");
		 dict23.addElement("string").addText(picUrl);
		 
		 
		 dict1.addElement("key").addText("metadata");
		 
		 Element dict1dict = dict1.addElement("dict");
		 
		 // ipa相关信息
		 dict1dict.addElement("key").addText("bundle-identifier");
		 dict1dict.addElement("string").addText(ipaPackage);
		 dict1dict.addElement("key").addText("bundle-version");
		 dict1dict.addElement("string").addText(ipaVersion);
		 dict1dict.addElement("key").addText("kind");
		 dict1dict.addElement("string").addText("software");
		 dict1dict.addElement("key").addText("title");
		 dict1dict.addElement("string").addText(ipaName);
		 
		 File file = new File(xmlPath);
		 if (file.exists()) {
			 file.delete();
		 }
	  
	     FileOutputStream fos = new FileOutputStream(xmlPath);  
	     OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");  
	     OutputFormat of = new OutputFormat();  
	     of.setEncoding("UTF-8");  
	     of.setIndent(true);  
	     of.setNewlines(true);  
	     XMLWriter writer = new XMLWriter(osw, of);  
	     writer.write(document);  
	     writer.close(); 
	}


	public static void qrCodeEncode(String encodeddata, File destFile) throws IOException { 
		 Qrcode qrcode = new Qrcode();  
		 qrcode.setQrcodeErrorCorrect('M');
		 qrcode.setQrcodeEncodeMode('B');      
		 qrcode.setQrcodeVersion(7);     
		 byte[] d = encodeddata.getBytes("UTF-8"); 
		 BufferedImage bi = new BufferedImage(139, 139, BufferedImage.TYPE_INT_RGB);
		 Graphics2D g = bi.createGraphics(); 
		 g.setBackground(Color.WHITE);   
		 g.clearRect(0, 0, 139, 139); 
		 g.setColor(Color.BLACK);    
		 if (d.length > 0 && d.length < 123) { 
			 boolean[][] b = qrcode.calQrcode(d);  
			 for (int i = 0; i < b.length; i++) { 
				  for (int j = 0; j < b.length; j++) {  
					  if (b[j][i]) { 
						  g.fillRect(j * 3 + 2, i * 3 + 2, 3, 3); 
					  }
				  }
			 }
		 }
		 g.dispose(); 
		 bi.flush(); 
		 ImageIO.write(bi, "png", destFile);  
		 System.out.println("Input Encoded data is:" + encodeddata);  
	 }

}
正则表达式
public class ValidateUtil {

	/**
	 * 校验下划线,字母,数字
	 * @param str
	 * @return
	 */
	public static boolean checkString(String str) {
		if (str == null) {
			return false;
		}
		String pattern = "^[\\w\\d_]+$";
		Pattern r = Pattern.compile(pattern);

		// 现在创建 matcher 对象
		Matcher m = r.matcher(str);
		return m.find();
	}

	/**
	 * 校验数字
	 * @param str
	 * @return
	 */
	public static boolean checkNum(String str) {
		if (str == null) {
			return false;
		}
		String pattern = "^[\\d]+$";
		Pattern r = Pattern.compile(pattern);

		// 现在创建 matcher 对象
		Matcher m = r.matcher(str);
		return m.find();
	}

	/**
	 * 校验邮箱
	 * @param str
	 * @return
	 */
	public static boolean checkEmail(String str) {
		if (str == null) {
			return false;
		}
		String pattern = "^[\\w\\d_]+@[\\w\\d]+[.]+[\\w\\d]+$";
		Pattern r = Pattern.compile(pattern);

		// 现在创建 matcher 对象
		Matcher m = r.matcher(str);
		return m.find();
	}


}
jws
web.xml

	<servlet>
		<servlet-name>jaxws</servlet-name>
		<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>jaxws</servlet-name>
		<url-pattern>/services</url-pattern>
	</servlet-mapping>


sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>  
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">  

    <!-- 服务路径http://网站路径//webservice/user -->  
    <endpoint name="user" implementation="com.infosec.webservcie.service.impl.UserWebServiceImpl" url-pattern="/webservice/user" />
</endpoints>  



@WebService(serviceName="user")
@SOAPBinding(style = SOAPBinding.Style.RPC)  
public class UserWebServiceImpl extends BaseWebService implements UserWebService {

	@WebResult(name="result") 
	public String getUserInfo(@WebParam(name="username")String username,
			@WebParam(name="tattedcode")String tattedcode,
			@WebParam(name="imei")String imei,
			@WebParam(name="usertype")String usertype
			);
}

jquery js jquery js
支持IE9及以上,chorme,等
var data1=$("#updateform").serialize();
$.ajax({
  	url:path+"/dept/addDept.action",
  	type : 'post',
  	dataType : 'json',
  	data:data1,
  	success : function(data) {
  			
  		if (data.flag == "true") {
				
				
		} else {
				
		}
  	}
 });


	$('#addAppForm').ajaxSubmit({
		url : path + "/appShop/addApp.action",
		success : function(data) {
			if (flag) {
				if (data.indexOf(">") > -1) {
					data = data.substring(data.indexOf(">")+1, data.lastIndexOf("<")); 
				}
				data = JSON.parse(data);
			} else {
				
				var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
				if (!(userAgent.indexOf("Chrome") > 0)) {
					data = JSON.parse(data);
				}; //判断是否IE浏览器
			}

		}
	});




  $("#updateform input[name='deptInfo.id']").val("abc");

 $("#dUpdateTime").text('label');



 $("#editAppForm select[name='isApp']").val('abc');
$("#editAppForm select[name='isApp'] option[value='cc']").attr("selected", "selected");



$('input:checkbox').each( function() {
		if(true == $(this).is(':checked')){
			
			if ($(this).attr("id") != 'check-all') {
				data = data + $(this).attr("name") + "@@";
			}
		} 
	});



$("#searchform")[0].reset();
	  $("#searchform select[name='userInfos.deptId'] option[value='']").attr("selected", "selected");
	   
	   $("#searchform div[name='serachInput']").each(function(){
			$(this).empty();
			$(this).append("全部");
	   });
appcationcontext 对象获取 spring applicationcontext
public class SpringContextUtils implements ApplicationContextAware{

	private static ApplicationContext applicationContext;
	/**
	 * 获取applicationContext对象
	 * @return
	 */
	public static ApplicationContext getApplicationContext(){
		return applicationContext;
	}

	/**
	 * 根据bean的id来查找对象
	 * @param id
	 * @return
	 */
	public static Object getBeanById(String id){
		return applicationContext.getBean(id);
	}

	/**
	 * 根据bean的class来查找对象
	 * @param c
	 * @return
	 */
	public static Object getBeanByClass(Class c){
		return applicationContext.getBean(c);
	}

	/**
	 * 根据bean的class来查找所有的对象(包括子类)
	 * @param c
	 * @return
	 */
	public static Map getBeansByClass(Class c){
		return applicationContext.getBeansOfType(c);
	}

	@Override
	public void setApplicationContext(ApplicationContext context) throws BeansException {
		this.applicationContext = context;
	}


}
Global site tag (gtag.js) - Google Analytics