解決SoapUI的Request URL不支持大寫
在SoapUI的Request URL中,每次輸入的URL中含有的大寫字母會自動轉(zhuǎn)換為小寫字母,導致請求不了,這個問題在SoapUI 5.1.2和5.2.1版本中都存在,具體的解決辦法是在HTTP TestRequest Properties的屬性中,在Endpoint中輸入對應的含有大寫字母的URL即可。

posted @ 2017-03-23 10:27 何云隆 閱讀(402) | 評論 (0) | 編輯 收藏
2013年5月27日 #
posted @ 2017-03-23 10:27 何云隆 閱讀(402) | 評論 (0) | 編輯 收藏
Java使用網(wǎng)易郵箱服務(wù)器發(fā)送郵件實例
1 下載發(fā)送mail需要的jar包
activation.jar 與 mail.jar
2 創(chuàng)建 SendMail 類
3 代碼如下
import java.util.Date;
import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import cn.founder.common.globals.Constants;
public class SendMail {
public int send(String tfrom, String tto, String ttitle, String tcontent) {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.263.net");//自己到網(wǎng)上查找網(wǎng)易發(fā)郵件的smtp服務(wù)地址 你的發(fā)件郵箱如果是163 你就查找163的發(fā)件服務(wù)器
props.put("mail.smtp.auth", "true");
Session s = Session.getInstance(props, null);
s.setDebug(true);
Message message = new MimeMessage(s);
try {
Address from = new InternetAddress(tfrom);
message.setFrom(from);
Address to = new InternetAddress(tto);
message.setRecipient(Message.RecipientType.TO, to);
sun.misc.BASE64Encoder enc = new sun.misc.BASE64Encoder();
message.setSubject("=?utf-8?B?"+enc.encode(ttitle.getBytes("utf-8"))+"?=");
message.setContent(tcontent, "text/html;charset=utf-8");
message.setSentDate(new Date());
message.saveChanges();
Transport transport = s.getTransport("smtp");
//第一個參數(shù)是發(fā)件服務(wù)器 第二個是你發(fā)件的郵箱名 第三個是你發(fā)件郵箱的密碼
transport.connect("smtp.263.net",”發(fā)件郵箱”,”發(fā)件郵箱密碼”);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
return 0;
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}
/**
* getEmailServiceIp
* @return EmailServiceIp
*/
public static void main(String[] args) {
//第一個參數(shù) 發(fā)件郵箱 第二個收件郵箱 第三個 郵件內(nèi)容
new SendMail().send("yunlong090614@163.com", "1063342004@qq.com", "更改密碼校驗", "尊敬的用戶你好,您的校驗碼為:65432</br>xxxx");
}
posted @ 2016-04-03 11:04 何云隆 閱讀(156) | 評論 (0) | 編輯 收藏
posted @ 2015-10-09 09:57 何云隆 閱讀(392) | 評論 (0) | 編輯 收藏
安裝32位的Oracle客戶端( instantclient-basic-win32-11.2.0.1.0)。Win7 64位系統(tǒng)暫無PLSQLDeveloper,所以下一個32位的。
下載instantclient-basic-win32-11.2.0.1.0.zip (一定得是32位的,不要下錯了版本,Oracle官網(wǎng)有下載),將其解壓至Oracle安裝目錄的Product下(本機命名為:instantclient_11_2):D:\Oracle\app\Dell\product\instantclient_11_2
拷貝數(shù)據(jù)庫安裝根目錄下的一個文件夾:D:\Oracle\app\Dell\product\11.2.0\dbhome_1
\NETWORK到Oracle客戶端目錄下D:\Oracle\app\Dell\product\instantclient_11_2(其實只需要 NETWORK\ADMIN\tnsnames.ora)
posted @ 2015-09-29 15:47 何云隆 閱讀(143) | 評論 (0) | 編輯 收藏
posted @ 2015-09-01 13:25 何云隆 閱讀(399) | 評論 (0) | 編輯 收藏
posted @ 2015-08-30 08:10 何云隆 閱讀(187) | 評論 (0) | 編輯 收藏
Java中的三元運算符為:條件?條件為true值:條件為false的值
EL也有一樣的運算符,用EL的三元運算符有時可以代替c:choose標簽,為我們的工作省下很大力氣。
比如gender為0顯示男,其余顯示女,我們可以這么寫:
<c:choose>
<c:when test="${gender eq 0}">男</c:when>
<c:otherwise>女</c:otherwise>
</c:choose>
但是不是顯得太麻煩了?其實我們這里就可以使用EL表達式中的三元運算符了,上面可以簡化為:
${gender eq 0?"男":"女"}
這樣是不是簡練了很多?在JSTL和EL處理非A即B的時候,三元運算符簡單了許多。
轉(zhuǎn)載請注明:觀測者 » JSP中EL表達式三元運算符的使用
posted @ 2015-08-25 11:03 何云隆 閱讀(2733) | 評論 (0) | 編輯 收藏
posted @ 2015-05-08 11:22 何云隆 閱讀(445) | 評論 (0) | 編輯 收藏
產(chǎn)生這種情況大多是因為上次svn命令執(zhí)行失敗且被鎖定了,需要刪除文件夾中的lock文件,即可解鎖。這里介紹3種方法:
方法一.直接進行cleanup;對較小的文件比較管用,文件稍大些等待時間很長或不起作用;
方法二.選擇文件,右鍵執(zhí)行release lock;等待時間較長;
方法三.手動刪除鎖定文件:
1.在運行中輸入cmd進入命令行; 2.在命令提示符下cd 到svn項目出現(xiàn)問題的文件所在目錄下; 3.執(zhí)行命令del lock /q/s 4.等待刪除lock文件成功,重新更新SVN。
posted @ 2015-03-25 15:03 何云隆 閱讀(291) | 評論 (0) | 編輯 收藏
posted @ 2014-08-26 16:18 何云隆| 編輯 收藏
打開eclipse彈出Error:could not open D:\java\lib\i386\jvm.cfg'
運行中 輸入regedit
沒有修改注冊表,解決辦法是:
重新安裝JDK時注冊表中\(zhòng)HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environemt\1.6 項目下的JavaHome和RuntimeLib設(shè)置沒有更新,將這兩個項目更正即可.
posted @ 2014-05-24 22:05 何云隆 閱讀(547) | 評論 (0) | 編輯 收藏
現(xiàn)在就暫先不管Eclipse Tidy了,看看如何安裝Eclipse HTML Editor。
1.下載GEF(依賴包):
然后解壓,把解壓得到的features和plugins兩文件夾放到eclipse安裝目錄下plugins文件夾中
2.下載HTMLEditor
http://amateras.sourceforge.jp/cgi-bin/fswiki_en/wiki.cgi?page=EclipseHTMLEditor
只有一個tk.eclipse.plugin.htmleditor_2.1.0.jar文件
直接復制到eclipse\plugins里面
posted @ 2014-04-03 15:15 何云隆 閱讀(176) | 評論 (0) | 編輯 收藏
posted @ 2014-03-03 19:30 何云隆 閱讀(351) | 評論 (0) | 編輯 收藏
創(chuàng)建重復的背景圖片
在drawable目錄下創(chuàng)建一個repeat_bg.xml: src是引用圖片的名稱
然后在布局的xml文件中可以這樣引用:
1
2
3
4
5
6
7
8 |
1 <LinearLayout android:layout_width= "fill_parent" 2 android:layout_height= "fill_parent" 3 android:background= "@drawable/repeat_bg" > 4 </LinearLayout> |
posted @ 2014-02-16 09:59 何云隆 閱讀(204) | 評論 (0) | 編輯 收藏
posted @ 2014-01-09 13:34 何云隆 閱讀(138) | 評論 (0) | 編輯 收藏
前言
本章內(nèi)容是android.widget.CompoundButton,翻譯來自德羅德,再次感謝德羅德 !期待你一起參與Android API 的中文翻譯,聯(lián)系我over140@gmail.com。
轉(zhuǎn)載
正文
一、結(jié)構(gòu)
public abstract class CompoundButton extends Button implements Checkable
java.lang.Object
二、概述
一個帶有選中/未選中狀態(tài)的按鈕。當按鈕按下或點中時自動改變狀態(tài)。
三、公共方法
public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)
在子視圖的構(gòu)建時分派一個輔助事件。(譯者注:通過源碼可以看出,視圖構(gòu)建時設(shè)置其選中狀態(tài)。)
參數(shù)
event 事件
返回值
如果事件全部完成返回True。
public boolean isChecked ()
(譯者注:是否選中)
public void onRestoreInstanceState (Parcelable state)
允許視圖重新應用以前通過onSaveInstanceState()生成代表內(nèi)部的狀態(tài)。這個函數(shù)決不調(diào)用一個空的狀態(tài)。
參數(shù)
state 返回以前調(diào)用onSaveInstanceState()保存下來的狀態(tài)。
public Parcelable onSaveInstanceState ()
允許視圖生成一個代表內(nèi)部的狀態(tài),以后可用于創(chuàng)建一個與之相同的新的實例。這種狀態(tài)應該只包含非持久或以后不能夠重建的信息。例如,你決不存儲你當前在屏幕上的位置,因為這會在視圖的層面上重新計算放置一個新的實例。
你可以存儲到這里的一些例子:一個文本框中當前光標的位置(但通常不是文字本身,文字通常保存在內(nèi)容提供者(content provider)或其他持久的儲存中),一個列表視圖中的當前選中項。
返回值
返回一個包含視圖當前狀態(tài)的Parcelable對象,或沒有什么狀態(tài)保存時返回null。默認實現(xiàn)返回null。
public boolean performClick ()
如果視圖定義了OnClickListener監(jiān)聽器,調(diào)用此方法來執(zhí)行。
返回值
定義了的OnClickListener被調(diào)用返回True,否則返回False
public void setButtonDrawable (Drawable d)
給按鈕背景設(shè)置一個可繪制對象(如:圖像)
參數(shù)
d 用作背景的可繪制對象(如:圖像)
public void setButtonDrawable (int resid)
通過資源Id給按鈕背景設(shè)置一個圖像
參數(shù)
resid 作為背景圖像的資源id
public void setChecked (boolean checked)
改變按鈕的選中狀態(tài)
參數(shù)
checked true選中,false非選中
public void setOnCheckedChangeListener (CompoundButton.OnCheckedChangeListener listener)
注冊一個在按鈕狀態(tài)發(fā)生改變時執(zhí)行的回調(diào)函數(shù)
參數(shù)
listener 當選中狀態(tài)改變時調(diào)用的函數(shù)
public void toggle ()
改變選中狀態(tài)為當前狀態(tài)的逆狀態(tài)
四、受保護方法
protected void drawableStateChanged ()
在視圖狀態(tài)的變化影響到所顯示可繪制的狀態(tài)時調(diào)用這個方法。
確保在重載時中調(diào)用父類方法
protected int[] onCreateDrawableState (int extraSpace)
為當前視圖生成新的可繪圖區(qū)狀態(tài)。這個方式當緩存的圖像繪圖區(qū)狀態(tài)確定失效時通過視圖系統(tǒng)調(diào)用。你可以使用getDrawableState()方法重新取得當前的狀態(tài)。
參數(shù)
extraSpace 如果為非零,這是你應該返回的數(shù)組在你可以存放你的狀態(tài)的額外條目的數(shù)量。
返回值
返回一個記錄著視圖中當前繪圖區(qū)狀態(tài)的數(shù)組
protected void onDraw (Canvas canvas)
實現(xiàn)你自己的繪制。
參數(shù)
canvas 在畫布上繪制背景
protected boolean verifyDrawable (Drawable who)
如果你的視圖子類顯示他自己的可視化對象,他將要重寫此方法并且為了顯示可繪制返回true。此操作允許進行繪制時有動畫效果。
確認當重寫從方法時,需調(diào)用父類相應方法。
參數(shù)
who 需判斷的可繪制對象(Drawable)。如果是你要顯示的對象,返回True,否則返回調(diào)用父類的結(jié)果。
返回值
boolean 如果可繪制對象(Drawable)已經(jīng)在視圖中顯示,返回True否則返回false。并且此處不允許使用動畫。posted @ 2013-12-20 22:43 何云隆 閱讀(183) | 評論 (0) | 編輯 收藏
posted @ 2013-12-19 19:55 何云隆 閱讀(146) | 評論 (0) | 編輯 收藏
別人覺得你是不是在打工,這個不重要。重要的是你自己千萬別把自己當成打工的,換個角度去看,是公司給你發(fā)工資,替你交學費,練著你自己的能力和經(jīng)驗。你遇到產(chǎn)品經(jīng)理、技術(shù)高手,或者公司創(chuàng)始人,從他們身上學到成功的經(jīng)驗,甚至是失敗的教訓。
我覺得有的人對創(chuàng)業(yè)的理解有誤區(qū)。他們把創(chuàng)業(yè)理解成幾個哥們開一個公司,回去印幾盒名片,我叫董事局主-席,你叫首席執(zhí)行官,自己的同學脖子上都掛上個CXO,名字很洋氣,也不知道什么意思。如果把這個理解為創(chuàng)業(yè)就大錯特錯。
我希望大家這樣來理解創(chuàng)業(yè),把創(chuàng)業(yè)看成是一種心態(tài),為了實現(xiàn)一個目標,孜孜不倦的去追求。只要你不滿足于現(xiàn)狀,想法設(shè)法去突破,那就是創(chuàng)業(yè)。如果你是一個在校學生,是搞電腦,如果你不滿足于只是把學分學好,不滿足于把考試應付好,而是花了很多時間提高你的編程能力,下了很大功夫來研究很多軟件,那這也是創(chuàng)業(yè)。學習是這樣,工作也是這樣,只要你勇敢的正視問題,積極的去解決問題,敢于去承擔未來的風險,這其實就是創(chuàng)業(yè)心態(tài)。
如果我們把創(chuàng)業(yè)都理解成我今天出去成立一個公司,明天上市,后天市值超越Facebook,對不起,從來沒有過這樣成功的例子。天底下哪里有這么一帆風順的事?把你放在一馬平川的大平原上,你憑著直覺沿著直線走,其實從高空看下去,你走出來的路是彎的,是曲折的。創(chuàng)業(yè)也是一樣,雖然心里有個目標,但是要達到那個目標,你得解決一個個實際的問題。人的路都是一步一步走出來的,而且這個路一定不是直線。
在中國更是這樣,環(huán)境確實太復雜了。特別是在創(chuàng)業(yè)早期,你沒有經(jīng)驗,沒有資源,你頭腦里的創(chuàng)新可能僅僅就是一個想法,一個主意,但如果實現(xiàn)不了,那它就什么都不是。但是,要實現(xiàn)這個想法,這個主意,你需要有判斷力,需要有經(jīng)驗,需要有知識。所以,我一直提倡大學生剛畢業(yè)的時候,不要頭腦一熱就攢出一個公司來,最好的方法是加入一家創(chuàng)業(yè)公司,甚至可以加入風險很大的種子公司,去學習創(chuàng)業(yè),感受創(chuàng)業(yè)。
很多人說,我加入別人的公司,那我不就成了一個打工的了嗎?給別人打工,誰認真干呀。錯了,如果你覺得自己是打工的,那你一輩子都是打工的。別人覺得你是不是在打工,這個不重要。重要的是你自己千萬別把自己當成打工的,換個角度去看,是公司給你發(fā)工資,替你交學費,練著你自己的能力和經(jīng)驗。你遇到產(chǎn)品經(jīng)理、技術(shù)高手,或者公司創(chuàng)始人,從他們身上學到成功的經(jīng)驗,甚至是失敗的教訓。
如果你加入這個公司,這個公司兩年之后死了,恭喜你,你一分錢沒損失,你參與一個活生生的公司從生到死的例子,你以后就可以避免重蹈覆轍。你一分錢沒花,你讓一個公司死了一回,你學到了如何避免失敗的教訓,這是一個多么值的事。這比你拿多少工資,比你到一個有名的大公司,有用多了。
別人一見你,都說你在北京某大公司工作,太了不起。那都是虛榮心,一點意義沒有。所以我一直強調(diào),如果你懷著創(chuàng)業(yè)的心態(tài),那么你在什么狀態(tài)都可以叫創(chuàng)業(yè)。等到有一天,當你有一股強烈的沖動要辦公司去創(chuàng)業(yè)的時候,有可能你會發(fā)現(xiàn),人各有所長,你不一定是做CEO的料,但你可能是優(yōu)秀的CTO,你可能是很好的銷售主管,這個時候你就知道找什么樣的合伙人去創(chuàng)業(yè)了。
所以,我鼓勵大家創(chuàng)業(yè),其實是鼓勵大家培養(yǎng)創(chuàng)業(yè)的精神,我不主張各位一定要出去成立一個公司,那只是一個形式。美國硅谷很多人不是先裝模作樣地成立一個公司,而是在家里的車庫,利用業(yè)余時間先搞出來一個產(chǎn)品,這也是創(chuàng)業(yè)的一部分。
我不希望傳授什么成功學,我最希望大家能夠想清楚未來幾年自己心里想要什么。在你創(chuàng)業(yè)的時候,不論遇到誘惑還是遇到挑戰(zhàn),都能夠記住我說的那句話:拒絕平庸,與眾不同。你不一定要追隨當時的主流,也要能耐得住寂寞,甚至要有一種韌性,敢于屢敗屢戰(zhàn),在未來長達五年或者八年、十年的時間里一直堅韌不拔地去探索,我相信五年以后、十年以后,可能中國新一代的企業(yè)家,中國新一代的創(chuàng)新領(lǐng)袖應該從各位里面誕生。
posted @ 2013-12-18 22:24 何云隆 閱讀(165) | 評論 (0) | 編輯 收藏
posted @ 2013-12-14 23:04 何云隆 閱讀(145) | 評論 (0) | 編輯 收藏
BaseAdapter方式
activity_main.xml
<LinearLayout xmlns:android=" xmlns:tools=" xmlns:android1=" android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android1:id="@+id/listView1"
android1:layout_width="match_parent"
android1:layout_height="wrap_content"
android1:layout_weight="1" >
</ListView>
</LinearLayout>
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical"
android:id="@+id/waibubuju"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bianhao"
android:text="編號"
android:textColor="#88ff0000"
android:gravity="center"
android:textSize="18sp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/neibubuju"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名"
android:id="@+id/username"
/>
MainActivity.java
package com.hyl.listViewpack;
import java.util.ArrayList;
import android.R.string;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
public class MainActivity extends Activity {
protected static final String TAG = "MainActivity";
private ListView listView1;
ArrayList<ArrayList<String>> arr ;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView1=(ListView) findViewById(R.id.listView1);
arr=new ArrayList<ArrayList<String>>();
for(int i=0;i<=50;i++){
ArrayList<String> a=new ArrayList<String>();
a.add("編號:"+i);
a.add("姓名:"+i);
a.add("電話:"+i);
arr.add(a);
}
listView1.setAdapter(new BaseAdapter() {
public View getView(int position, View convertView, ViewGroup parent) {
//父窗體 掛載
View view=View.inflate(MainActivity.this, R.layout.list_item, null);
Log.e(TAG, "測試創(chuàng)建對象位置:"+position);
ArrayList<String> a=arr.get(position);
TextView tvbianhao=(TextView) view.findViewById(R.id.bianhao);
tvbianhao.setText( a.get(0));
TextView tvUserName=(TextView) view.findViewById(R.id.username);
tvUserName.setText( a.get(1));
TextView tvTel=(TextView) view.findViewById(R.id.tel);
tvTel.setText( a.get(2));
return view;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getCount() {
return arr.size();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="電話"
android:id="@+id/tel"
/>
</LinearLayout>
</LinearLayout>
ArrayAdapter方式
//上下文對象 布局列表對象 顯示的TextView的ID 數(shù)組對象
listView1.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.bianhao, new String[]{"選項一","選項二","選項三","選項四","選項五"}));
SimpleAdapter方式
listView1=(ListView) findViewById(R.id.listView1);
ArrayList<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
Map<String, Object> map1=new HashMap<String, Object>();
map1.put("icon", R.drawable.ic1);
map1.put("name", "功能一");
list.add(map1);
Map<String, Object> map2=new HashMap<String, Object>();
map2.put("icon", R.drawable.ic2);
map2.put("name", "功能二");
list.add(map2);
Map<String, Object> map3=new HashMap<String, Object>();
map3.put("icon", R.drawable.ic3);
map3.put("name", "功能三");
list.add(map3);
Map<String, Object> map4=new HashMap<String, Object>();
map4.put("icon", R.drawable.ic1);
map4.put("name", "功能四");
list.add(map4);
Map<String, Object> map5=new HashMap<String, Object>();
map4.put("icon", R.drawable.ic5);
map4.put("name", "功能五");
list.add(map5);
listView1.setAdapter(new SimpleAdapter(this, list, R.layout.list_item, new String[]{"icon","name"},new int[]{R.id.tubiao,R.id.gongneng} ));
posted @ 2013-12-10 21:00 何云隆 閱讀(379) | 評論 (0) | 編輯 收藏
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_list_activy);
lv_show_view = (ListView) findViewById(R.id.lv_show_view);
AsyncHttpClient client=new AsyncHttpClient();
String url = " + "測試方法";
client.get(url, new AsyncHttpResponseHandler() {
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
List<Video> list=new ArrayList<Video>();
try {
Toast.makeText(ShowListActivy.this,statusCode+"", 1).show();
String json = new String(responseBody);
JSONArray array = new JSONArray(json);
for(int i=0 ; i < array.length() ; i++){
JSONObject item= array.getJSONObject(i);
String id = item.getString("id");
String title = item.getString("title");
String timelength = item.getString("time");
Log.e("jsonget", id+title+timelength);
list.add(new Video( id, title, Integer.parseInt(timelength)));
}
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
for (Video v : list) {
Map<String, Object> it = new HashMap<String, Object>();
it.put("id", v.getId());
it.put("title", v.getTitle());
it.put("timelength", v.getTime());
data.add(it);
}
SimpleAdapter adapter = new SimpleAdapter(ShowListActivy.this, data,R.layout.item, new String[] { "title", "timelength" },new int[] { R.id.title, R.id.timelength });
lv_show_view.setAdapter(adapter);
} catch ( Exception e) {
Log.e("MainActivity", e.toString());
}
}
public void onFailure(int statusCode, Header[] headers,
byte[] responseBody, Throwable error) {
Toast.makeText(ShowListActivy.this,"shibai", 1).show();
}
});
顯示出傳過來的json結(jié)果:
本文章只是自己學習筆記,大家要慎重借鑒
posted @ 2013-12-03 14:30 何云隆 閱讀(318) | 評論 (0) | 編輯 收藏
package com.shxt.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URLEncoder;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DownLoadServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("application/x-msdownload");
PrintWriter out = response.getWriter();
response.reset();// 可以加也可以不加
response.setContentType("application/x-download");
String filedownload = request.getRealPath("/images")
+ "\\02_開發(fā)第一個無狀態(tài)會話bean.avi";// "想辦法找到要提供下載的文件的物理路徑+文件名";
System.out.print(filedownload);
String filedisplay = "okokok.avi";// "給用戶提供的下載文件名";
filedisplay = URLEncoder.encode(filedisplay, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename="
+ filedisplay);
OutputStream outp = null;
FileInputStream in = null;
try {
outp = response.getOutputStream();
// 你可以指定你的ftp輸入流
in = new FileInputStream(new File(filedownload));
byte[] b = new byte[1024];
int i = 0;
while ((i = in.read(b)) > 0) {
outp.write(b, 0, i);
}
outp.flush();
} catch (Exception e) {
System.out.println("Error!");
e.printStackTrace();
} finally {
if (in != null) {
in.close();
in = null;
}
if (outp != null) {
outp.close();
outp = null;
}
//out.clear();
//out = pageContext.pushBody();
}
}
}
posted @ 2013-11-23 20:51 何云隆 閱讀(924) | 評論 (1) | 編輯 收藏
posted @ 2013-11-22 16:55 何云隆 閱讀(1848) | 評論 (2) | 編輯 收藏
經(jīng)過試驗后發(fā)現(xiàn)HTML錨點在JSP中并不兼容。兩者表示錨點的方法有所不同
HTML錨點
<a href="#1">goto1</a>
.
.
.
.
<a name="1">111</a>
這樣從goto1可以定位到111
JSP錨點
<a href="javascript:void(0)" onclick="document.getElementById('1').scrollIntoView();">goto1</a>
。
。
。
<a id="1">1111</a>
posted @ 2013-09-18 16:49 何云隆 閱讀(320) | 評論 (0) | 編輯 收藏
posted @ 2013-07-10 10:41 何云隆 閱讀(1397) | 評論 (1) | 編輯 收藏
function openAndClose(myelement) {
alert(myelement.attributes["value"].value );
}
posted @ 2013-05-29 21:42 何云隆 閱讀(851) | 評論 (1) | 編輯 收藏
posted @ 2013-05-27 15:41 何云隆 閱讀(297) | 評論 (0) | 編輯 收藏