@java
@フォロワー #0
[Android]JavaにてMD5 値の取得方法について @java @code @Android
iQi @回答 • 2015-03-13 10:26 • @フォロワー #2 • 1 回答 • 3040 Views
[JAVA]String(文字列)を大文字・小文字変換する方法について @java @Android
iQi @回答 • 2015-03-12 14:57 • @フォロワー #1 • 1 回答 • 1441 Views
[Android]AndroidからHTTP-POST通信でバイト列を送信する方法について @java @code @Android
iQi @回答 • 2015-03-12 14:21 • @フォロワー #2 • 1 回答 • 3915 Views
Struts2でiteratorタグでListの中身取得方法を教えてください @struts @java
iQi @回答 • 2015-02-13 14:45 • @フォロワー #2 • 1 回答 • 7487 Views
表示側test.jsp:
{{{
<s:iterator value="dataList" status="list">
<tr>
<td> <s:property value...
{{{
<s:iterator value="dataList" status="list">
<tr>
<td> <s:property value="id" /></td>
<td> <s:property value="name" /></td>
</tr>
</s:iterator>
}}}
Action側TestAction.java:
{{{
private List dataList;
@Override
public String execute() throws Exception {
dataList = new ArrayList();
TestDTO testDTO = new TestDTO();
testDTO.setId("1");
testDTO.setName("名前1");
dataList.add(testDTO);
testDTO = new TestDTO();
testDTO.setId("2");
testDTO.setName("名前2");
dataList.add(testDTO);
testDTO = new TestDTO();
testDTO.setId("3");
testDTO.setName("名前3");
dataList.add(testDTO);
return "page1";
}
}}}
DATA側:TestDTO.java
{{{
public class TestDTO {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}}}
{{{
URL url = new URL("http://yoururl.com");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.s...
URL url = new URL("http://yoururl.com");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setReadTimeout(10000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("firstParam", paramValue1));
params.add(new BasicNameValuePair("secondParam", paramValue2));
params.add(new BasicNameValuePair("thirdParam", paramValue3));
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
writer.write(getQuery(params));
writer.flush();
writer.close();
os.close();
conn.connect();
}}}
...
{{{
private String getQuery(List<NameValuePair> params) throws UnsupportedEncodingException
{
StringBuilder result = new StringBuilder();
boolean first = true;
for (NameValuePair pair : params)
{
if (first)
first = false;
else
result.append("&");
result.append(URLEncoder.encode(pair.getName(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode(pair.getValue(), "UTF-8"));
}
return result.toString();
}
}}}
{{{
public static String md5(String str) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.M...
public static String md5(String str) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(str.getBytes());
byte messageDigest[] = digest.digest();
// Create md5 String
StringBuffer md5String = new StringBuffer();
for (int i=0; i<messageDigest.length; i++){
String h = Integer.toHexString(0xFF & messageDigest[i]);
while (h.length() < 2){
h = "0" + h;
}
md5String.append(h);
}
System.out.println(str + ":" + md5String.toString());
return md5String.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return "";
}
}}}
{{{
String str = "Hello";
System.out.println("大文字へ変換 : " + str.toUpperCase());
System.out.println(...
String str = "Hello";
System.out.println("大文字へ変換 : " + str.toUpperCase());
System.out.println("小文字へ変換 : " + str.toLowerCase());
}}}