问题集合

来源:互联网 发布:深圳华夏软件学校骗 编辑:程序博客网 时间:2024/05/16 16:05

jdk和eclipse位数不匹配导致,用cmd打开命令控制行,输出java -version 出现位数为64,没出现即为32位


正则

[\s\S]*匹配包括\r\n在内的任意字符

java通过http post请求发送json数据
public static String sendPost(String urls, String param) {String result = "";try {URL url = new URL(urls);HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setDoInput(true);connection.setDoOutput(true);connection.setRequestMethod("POST");connection.setUseCaches(false);connection.setInstanceFollowRedirects(true);connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");connection.connect();DataOutputStream out = new DataOutputStream(connection.getOutputStream());out.writeBytes(param);out.flush();out.close();BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));String lines;StringBuffer sbf = new StringBuffer();while ((lines = reader.readLine()) != null) {lines = new String(lines.getBytes(), "utf-8");sbf.append(lines);}result = sbf.toString();System.out.println(sbf);reader.close();// 断开连接connection.disconnect();} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}return result;}

一开始一直不行因为
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");

写成了
 connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");  

Content-Type有以下几种类型声明

application/x-javascript text/xml->xml数据 application/x-javascript->json对象 application/x-www-form-urlencoded->表单数据 application/json;charset=utf-8 -> json数据  
参考自
http://blog.csdn.net/mingtianhaiyouwo/article/details/51381853



eclipse 导出war包

今天想把项目导出war发布,以前都是直接可以导出,现在居然不行,百度了也没有解决方法,然后问了同事,还是经验重要啊。。
选择项目点击右键->proferties->project facets
将Dynamic web module勾选为3.0 java勾选为所需版本。

0 0
原创粉丝点击