日期:2014-05-17 浏览次数:20747 次
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="struts2" extends="struts-default">
<action
name="request" class="com.afeiluo.GetRequestAction" method="getHttp">
</action>
</package>
</struts>
package com.afeiluo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.servlet.ServletInputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class GetRequestAction extends ActionSupport {
private String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public void getHttp(){
System.out.println("username:"+username);
System.out.println("am in getHttp");
}}
URL url = new URL("http://localhost:8080/TestWeb/request?username=ooxx");
URLConnection connection = url.openConnection();