当前位置:编程学习 > JAVA >>

jsp页面向PHP页面 post参数的问题

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"  import="java.net.*" errorPage="" %>
<%@page import="java.io.DataInputStream"%>
<%@ page import = 'bean.MD5' %>
<%

String UserId = "10006";
String key="tRCSz8mfgGyVkVWUVi85fjDMAqhwgsfA";
String  phone= "13705719123";//request.getParameter["Tel"];
MD5 md5 = new MD5();
String str1 = "10006" + "013738009123"+"tRCSz8mfgGyVkVWUVi85fjDMAqhwgsfA";
String pwdmd5 = md5.getMD5ofStr(str1);//(UserId+"0"+phone+key);

//if(!preg_match('/^[0-9]{11,13}$/',$phone))
//{
    //print("error");
//    exit();
//}
/*String md5=md5($UserId."0".$phone.$key);
//String curlPost = 'UserId='.$UserId.'&phone='.$phone.'&Md5Str='.$md5;
session.setAttribute("UserId",UserID);
session.setAttribute("phone",phone);
session.setAttribute("Md5Str",md5);*/





String curlPost = "UserId=" + UserId; //+ "&phone=" + phone + "&Md5Str=" + pwdmd5;
out.println(curlPost);
URL url = null;
HttpURLConnection httpurlconnection = null;
try {
   
   url = new URL("http://127.0.0.1:8081/webcode/outcallInte易做图ce.php");
    httpurlconnection = (HttpURLConnection)url.openConnection();
    httpurlconnection.setDoOutput(true);
    httpurlconnection.setRequestMethod("POST");
    httpurlconnection.setRequestProperty( "Cache-Control ",   "private "); 
    httpurlconnection.setRequestProperty( "Accept-Charset ",   "gb2312 "); 
    httpurlconnection.setRequestProperty( "Content-Type ",   "application/x-www-form-urlencoded ");   
    //String username = "username=02000001";
    httpurlconnection.getOutputStream().write(curlPost.getBytes("UTF-8"));
    httpurlconnection.getOutputStream().flush();
    httpurlconnection.getOutputStream().close();
    //String str = httpurlconnection.getResponseMessage();
   // System.out.println("code     " + str);
    DataInputStream inStream = new DataInputStream(
            httpurlconnection.getInputStream());
 
    int ch;
    while ((ch = inStream.read()) >= 0) {
        out.print((char) ch);
    }
} catch(Exception e) {
    e.printStackTrace();
} finally {
    if(httpurlconnection != null) {
        httpurlconnection.disconnect();
    }
}


[PHP code]$team_id=$_POST["UserId"];
echo($team_id);
$phone=$_POST["phone"];
$Md5str=$_POST["Md5Str"];
if(!PhoneTest($phone))
{
    print("0");
    exit;
}
$sql="select * from user_tabel where team_id='$team_id'";
$conn=new Connection();
$conn->Open();
$result=$conn->ExecuteQuery($sql);
$conn->Close();
if($row=mysql_fetch_array($result))
{
    $phone_callid=$row['phone_callid'];
    if(strlen($phone_callid)<=10)
        $phone_callid="013567036060";
    $key=$row['key'];
    $lead=$row['lead'];
    $count=(int)$row['count'];
    $call_money=(int)$row['call_money'];
}
else
{
    print("0");
    exit;
}
[/code]

我现在从第一个页面把参数POST到jsp页面 现在第二个PHP页面收不到POST参数,想问一下JSP页面出了什么问题 --------------------编程问答-------------------- 解决了吗??我也遇到同样的问题,我怀疑是因为java这样写是模拟的post,php端无法接收到 --------------------编程问答-------------------- 你看看你传的值有数据没的。
补充:Java ,  Web 开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,