我正在尝试将页面重定向到另一个页面以及查询字符串。 示例:
以下网址
http://example.com/firstdir/?abc=xyz
需要在同一个域中使用相同的查询字符串重定向到以下URL。
http://example.com/seconddir/?abc=xyz
如果网址中没有添加任何查询字符串,它应该保留在同一页面上,不会重定向。
我试图解释我在寻找什么,请帮助!!!
感谢你。答案 0 :(得分:0)
只需将.htaccess放入根文件夹即可处理递归文件夹。
答案 1 :(得分:0)
您可以在package me.shikhov.testmultispinner;
import android.app.Activity;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class MainActivityFragment extends Fragment{
private static final String TAG = "test-spinner";
private Spinner spinner1;
private Spinner spinner2;
private int spinner1Selection;
private int spinner2Selection;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
SharedPreferences sp = activity.getSharedPreferences("default", 0);
spinner1Selection = sp.getInt("spinner1", AdapterView.INVALID_POSITION);
spinner2Selection = sp.getInt("spinner2", AdapterView.INVALID_POSITION);
if(BuildConfig.DEBUG) {
Log.i(TAG, "spinner1 => " + spinner1Selection);
Log.i(TAG, "spinner2 => " + spinner2Selection);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
spinner1 = (Spinner) view.findViewById(R.id.spinner1);
spinner2 = (Spinner) view.findViewById(R.id.spinner2);
ArrayAdapter spinner1Adapter = new ArrayAdapter<>(getActivity(),
android.R.layout.simple_spinner_dropdown_item,
new String[]{"item1", "item2", "item3"});
spinner1.setAdapter(spinner1Adapter);
spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
boolean firstSelection = true;
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
if (BuildConfig.DEBUG) {
Log.i(TAG, "onItemSelected " + position + " firstSelection " + firstSelection);
}
String selected = ((String) spinner1.getSelectedItem());
spinner2.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
new String[]{
selected + " subItem1",
selected + " subitem2",
selected + " subitem3"}));
if (firstSelection) {
spinner2.setSelection(spinner2Selection);
firstSelection = false;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
spinner2.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new String[0]));
}
});
view.findViewById(R.id.next_fragment).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { getFragmentManager().beginTransaction().replace(R.id.fragments_root, new NextFragment()).commit();
}
});
spinner1.setSelection(spinner1Selection);
spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if(BuildConfig.DEBUG) {
Log.i(TAG, "spinner2 onItemSelected " + position);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
return view;
}
@Override
public void onPause() {
super.onPause();
SharedPreferences sp = getActivity().getSharedPreferences("default", 0);
if(BuildConfig.DEBUG) {
Log.i(TAG, "spinner1 := " + spinner1.getSelectedItemPosition());
Log.i(TAG, "spinner2 := " + spinner2.getSelectedItemPosition());
}
sp.edit().putInt("spinner1", spinner1.getSelectedItemPosition())
.putInt("spinner2", spinner2.getSelectedItemPosition())
.commit();
}
}
文件中使用此代码:
DOCUMENT_ROOT/.htaccess
查询字符串会自动转移到目标网址