补充 宝玉 之《URL欺骗之以假乱真!》之 POST 方法提交数据 之 处理!
(之乎者也,怪别扭的!)
我们首先搭建一个环境:
IIS 代理一下 Resin 下的 jsp 页面! (Resin 乃是 Java 应用服务器)
1.Resin 获取:
http://www.caucho.com/download/resin-2.1.16.zip
下载后解压某目录,如:
E:/Resin/resin-2.1.16/
2.配置 Resin (Java SDK 的配置就不赘述)
用文本编辑器打开:
E:/Resin/resin-2.1.16/conf/resin.conf
<http port='8080'/>
可配置端口,resin 默认的是 8080 !
如果可用就不改!
<welcome-file-list>simplepost.jsp ,index.xtp, index.jsp, index.html </welcome-file-list>
可配置默认欢迎页面!
3.在 E:/Resin/resin-2.1.16/webapps/ 下创建新目录 test:
编写 E:/Resin/resin-2.1.16/webapps/test/index.jsp 并保存!
E:/Resin/resin-2.1.16/webapps/test/ 就是一个 Application
<%@ page import='java.util.*'%>
<HTML>
<head>
<title>test</title>
</head>
<h1>Form Values:</h1>
<table>
<%
Enumeration e = request.getParameterNames();
while (e.hasMoreElements())
{
String name = (String) e.nextElement();
String[] values = (String[]) request.getParameterValues(name);
%>
<tr><td>
<%= name %><td><%= values[0] %>
<%
if (values.length > 1)
{
for (int i = 1; i < values.length; i++)
{
%>,<%= values[i] %><%
}
}
}
%>
</table>
<form action='http://localhost' method='post'>
<input name='Comment' type="text" value="<%= request.getParameter("Comment") %>">
<input name='Comment2' type="text" value="<%= request.getParameter("Comment2") %>">
<input type=submit>
</form>
</body>
</HTML>
4.编写 C# Openlab.UrlCheat.cs : (修改宝玉的代码基础上完成POST操作的处理)
//Openlab.UrlCheat.cs
//命令行编译: csc /t:library Openlab.UrlCheat.cs
//生成的 Openlab.UrlCheat.dll 存放在 IIS 主目录下建一个 bin 目录!
//如: C:/Inetpub/wwwroot/bin/Openlab.UrlCheat.dll
namespace Openlab.UrlCheat
{
using System;
using System.Configuration;
using System.Web;
using System.IO;
using System.Net;
using System.Text;
//原 Globals.cs
/// <summary>
/// Summary description for Globals.
/// </summary>
public class Globals