我需要知道如何提交HTML表单并检索数据。 我使用了How do you programmatically fill in a form and 'POST' a web page?
中的代码C#
dates Close max1 max2
2016-05-02 2219.30 NA NA
2016-05-03 2245.40 NA NA
2016-05-04 2151.10 2245.4 NA
2016-05-05 2092.20 2245.4 NA
2016-05-06 2104.15 2245.4 NA
2016-05-09 2106.00 2245.4 NA
2016-05-10 1987.25 2106 2245.4
2016-05-11 1967.25 2106 2245.4
2016-05-12 1870.95 2106 2245.4
2016-05-13 1862.80 2106 2245.4
2016-05-16 1795.15 2106 2245.4
2016-05-17 1722.45 2106 2245.4
2016-05-18 1661.05 2106 2245.4
2016-05-19 1582.50 2106 2245.4
2016-05-20 1739.50 2106 2245.4
2016-05-23 1729.65 1739.5 2106
2016-05-24 1685.20 1739.5 2106
2016-05-25 1714.30 1739.5 2106
2016-05-26 1709.55 1714.3 1739.5
2016-05-27 1710.45 1714.3 1739.5
2016-05-30 1683.60 1710.45 1714.3
2016-05-31 1692.55 1710.45 1714.3
2016-06-01 1708.90 1710.45 1714.3
2016-06-02 1700.05 1708.9 1710.45
2016-06-03 1685.85 1708.9 1710.45
2016-06-06 1666.35 1708.9 1710.45
2016-06-07 1654.60 1708.9 1710.45
2016-06-08 1644.95 1708.9 1710.45
2016-06-09 1644.85 1708.9 1710.45
2016-06-10 1644.25 1708.9 1710.45
2016-06-13 1744.10 1708.9 1710.45
2016-06-14 1704.85 1744.1 1708.9
2016-06-15 1703.70 1744.1 1708.9
2016-06-16 1688.55 1744.1 1708.9
2016-06-17 1831.15 1744.1 1708.9
JSP index.jsp的
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if (convertView == null) { // if it's not recycled, initialize some attributes
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
v = inflater.inflate(R.layout.gridview_item_layout, parent, false);
} else {
v = (View) convertView;
}
TextView text = (TextView)v.findViewById(R.id.grid_item_text);
text.setText(mTextIds[position]);
ImageView image = (ImageView)v.findViewById(R.id.grid_item_image);
image.setImageDrawable(mThumbIds[position]);
return v;
}
的success.jsp
WebRequest req =
WebRequest.Create("http://localhost:8080/Test/views/user/index.jsp");
string postData = "email=test&password=test";
byte[] send = System.Text.Encoding.Default.GetBytes(postData);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send.Length;
Stream sout = req.GetRequestStream ();
sout.Write (send, 0, send.Length);
sout.Flush ();
sout.Close ();
WebResponse res = req.GetResponse ();
StreamReader sr = new StreamReader (res.GetResponseStream ());
Debug.Log (sr.ReadToEnd ());
我希望得到<form action="/Test/views/user/success.jsp" action="POST">
<input type="text" id="email" name="email"> <br> <input
type="password" id="password" name="password"> <br> <input
type="submit" id="submit" name="submit" value="Submit"></form>
字符串,但上面的代码只返回HTML代码。
如何使用C#检索<'%
if(test.equals("test")){
out.print("true");
}
%'>
值? C#不驻留在服务器端,所以它是不可能的。