修复服务器上ng2 app的路由机制

时间:2017-05-27 09:15:41

标签: angular routing

我已经构建了一个带路由机制的ng2 app。虽然路由在localhost上运行良好,但路由机制部分在真实服务器上运行。我应该如何指出根目录中真实服务器上的index.html是路由器?任何人都可以解释它是.htaccess以及如何正确创建它或至少指出如何使用ng2文件创建.htaccess的参考资料?

1 个答案:

答案 0 :(得分:0)

将它放在.htaccess中,它会将所有网址指向index.html

//this is what my Log looks like
05-25 23:50:46.029 22283-22308/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                               Process: com.example.android.myquake, PID: 22283
                                               java.lang.RuntimeException: An error occured while executing doInBackground()
                                                   at android.os.AsyncTask$3.done(AsyncTask.java:300)
                                                   at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                                                   at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                   at java.lang.Thread.run(Thread.java:818)
                                                Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
                                                   at android.os.Handler.<init>(Handler.java:200)
                                                   at android.os.Handler.<init>(Handler.java:114)
                                                   at android.app.Activity.<init>(Activity.java:793)
                                                   at android.support.v4.app.BaseFragmentActivityGingerbread.<init>(BaseFragmentActivityGingerbread.java:34)
                                                   at android.support.v4.app.BaseFragmentActivityHoneycomb.<init>(BaseFragmentActivityHoneycomb.java:29)
                                                   at android.support.v4.app.BaseFragmentActivityJB.<init>(BaseFragmentActivityJB.java:29)
                                                   at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:77)
                                                   at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:64)
                                                   at com.example.android.myquake.MainActivity.<init>(MainActivity.java:0)
                                                   at com.example.android.myquake.Fesh.feshjson(Fesh.java:129)
                                                   at com.example.android.myquake.Fesh.fesh(Fesh.java:39)
                                                   at com.example.android.myquake.Arrayloader.loadInBackground(Arrayloader.java:28)
                                                   at com.example.android.myquake.Arrayloader.loadInBackground(Arrayloader.java:18)
                                                   at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:312)
                                                   at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:69)
                                                   at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:57)
                                                   at android.os.AsyncTask$2.call(AsyncTask.java:288)
                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                                   at java.lang.Thread.run(Thread.java:818)