我有一個服務器端應用程序,它運行在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