我有一个服务器端应用程序,它运行在Yii Framework
上。我想通过与Yii联系到数据库(MySQL)。Android HttpPost通过Yii Framework返回500
所以我从客户端发表这样的:
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("myurl/reach");
try {
List<NameValuePair> nmp = new ArrayList<NameValuePair>();
ResponseHandler<String> responseHandler=new BasicResponseHandler();
// Parameters are here
// nmp.add(new BasicNameValuePair("name", "value"));
httpPost.setEntity(new UrlEncodedFormEntity(nmp));
String rs = httpClient.execute(httpPost, responseHandler);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
这里是的Yii的urlManager
规则:
'/reach' => 'site/reach',
最后actionReach()
方法上siteController
:
if(Yii::app()->request->isPostRequest)
{
// Reach MySQL
} else
{
$this->redirect(Yii::app()->homeUrl);
}
当我试图运行的应用程序,刚开org.apache.http.client.HttpResponseException: Internal Server Error
这里是所有堆栈:
02-22 01:11:18.803: W/System.err(3924): org.apache.http.client.HttpResponseException: Internal Server Error
02-22 01:11:18.823: W/System.err(3924): at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:71)
02-22 01:11:18.823: W/System.err(3924): at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:59)
02-22 01:11:18.823: W/System.err(3924): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
02-22 01:11:18.823: W/System.err(3924): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
02-22 01:11:18.828: W/System.err(3924): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
02-22 01:11:18.828: W/System.err(3924): at com.app.myapp.PostActivity$postInfoTask.doInBackground(PostActivity.java:175)
02-22 01:11:18.828: W/System.err(3924): at com.app.myapp.PostActivity$postInfoTask.doInBackground(PostActivity.java:1)
02-22 01:11:18.828: W/System.err(3924): at android.os.AsyncTask$2.call(AsyncTask.java:185)
02-22 01:11:18.833: W/System.err(3924): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
02-22 01:11:18.833: W/System.err(3924): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
02-22 01:11:18.833: W/System.err(3924): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
02-22 01:11:18.833: W/System.err(3924): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
02-22 01:11:18.838: W/System.err(3924): at java.lang.Thread.run(Thread.java:1096)
最后但并非最不重要的,当我改变我的网址reach/
到reach
有没有错误,但Yii的甚至返回首页HTML输出如果我已经发布。
我错过了什么?是关于.htaccess
还是什么?
您首先需要在浏览器中尝试使用yii url来查看预期的输出。 – Arfeen 2012-02-22 05:36:02
并检查服务器上的php错误。当我得到错误500它主要是一些PHP错误 – 2012-02-22 07:18:52
也检查你的Yii路线。 “达到”有什么特殊规定吗?尝试加载apache日志和php错误日志以及 – 2012-02-22 08:49:17