是否可以使用包含字符" /"的字符串;在网址?

时间:2015-06-18 06:17:07

标签: ruby-on-rails url routes

我有一个带有public class fb extends Activity { Button fbbt1; CallbackManager callbackManager; AccessTokenTracker accessTokenTracker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fb); try { FacebookSdk.sdkInitialize(getApplicationContext()); fbbt1 = (Button) findViewById(R.id.fbbutton); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // App code } @Override public void onCancel() { // App code // savedInstanceState } @Override public void onError(FacebookException exception) { // App code Toast.makeText(fb.this, exception.toString(), Toast.LENGTH_LONG).show(); } }); LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile, user_groups")); accessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged( AccessToken oldAccessToken, AccessToken currentAccessToken) { } }; fbbt1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { getUserData(AccessToken.getCurrentAccessToken()); Toast.makeText(fb.this, "Access Token: "+ AccessToken.getCurrentAccessToken().getToken().toString(), Toast.LENGTH_LONG).show(); } catch (Exception e){ Toast.makeText(fb.this, "error is: "+e.toString(), Toast.LENGTH_LONG).show(); } } }); } catch (Exception e){ Toast.makeText(fb.this, e.toString(), Toast.LENGTH_LONG).show(); } } public void getUserData(AccessToken accessToken){ GraphRequest.newGraphPathRequest( accessToken, "/ 415004402015833/posts", new GraphRequest.Callback() { @Override public void onCompleted(GraphResponse graphResponse) { try { Toast.makeText(fb.this, "Object Length is : " + graphResponse.getJSONObject().length(), Toast.LENGTH_LONG).show(); Toast.makeText(fb.this, "request was: " + graphResponse.getRequest(), Toast.LENGTH_LONG).show(); String resp = graphResponse.getRawResponse(); Toast.makeText(fb.this, "response is: " + resp, Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(fb.this, "error is: " + e.toString(), Toast.LENGTH_LONG).show(); } } }).executeAsync(); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); callbackManager.onActivityResult(requestCode, resultCode, data); } @Override protected void onDestroy() { super.onDestroy(); try{ accessTokenTracker.stopTracking();} catch (Exception e){ Toast.makeText(fb.this, "error is: "+e.toString(), Toast.LENGTH_LONG).show(); } } } 属性的模型(类别),我为此定义了一条路线:

:name

问题是,某些类别的名称包含字符&#34; /&#34;。因此,例如,如果某个类别被命名为&#34;药物/药房&#34;,那么该网址将被解释为get ':name' => 'categories#show' ,而不是categories#Drugs#Pharmacy

还有其他人遇到过这个问题吗?我怎么能绕过这个?我想我可以从每个网址中删除该字符,但如果我能以某种方式包含它,那将会很酷。

0 个答案:

没有答案