문제 해결을 도와주세요.
나는 레일 5를 사용한다. 나는 간단한 사이트를 만든다.
kalinin@kalinin ~/rails/test5 $ rails routes
Prefix Verb URI Pattern Controller#Action
pages_home GET /pages/home(.:format) pages#home
pages_about GET /pages/about(.:format) pages#about
pages_portfolio GET /pages/portfolio(.:format) pages#portfolio
pages_blog GET /pages/blog(.:format) pages#blog
pages_contact GET /pages/contact(.:format) pages#contact
root GET / pages#home
홈페이지에는 두 가지 경로가 있습니다.
http://localhost:3000/pages/home
http://localhost:3000/
홈페이지에는 js-slider가 있습니다. 초기화 코드 :
function clearText(field)
{
if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue;
}
var flashvars = {};
flashvars.xml_file = "photo_list.xml";
var params = {};
params.wmode = "transparent";
var attributes = {};
attributes.id = "slider";
swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "960", "350", "9.0.0", false, flashvars, params, attributes);
ddsmoothmenu.init({
mainmenuid: "templatemo_menu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
문제 : 경로 http://localhost:3000/pages/home
에이 슬라이더가 표시되지 않습니다. 콘솔 출력은 오류 메시지를 따릅니다.
GET http : // localhost : 3000 / pages / photo_list.xml 404 (찾을 수 없음)
그러나 경로 http://localhost:3000/
슬라이더는 문제없이 표시됩니다.
ps : 경로 pages/photo_list.xml
가 존재하지 않습니다. 그러나 경로 public/photo_list.xml
가 있습니다.
PageController :
class PagesController < ApplicationController
def home
render layout: "home"
end
def about
end
def portfolio
render layout: "portfolio"
end
def blog
end
def contact
end
end
이 라인 때문입니다.
flashvars.xml_file = "photo_list.xml";
그것은 당신이있는 페이지와 관련이있을 것입니다. 그래서 당신이 http://localhost:3000/pages/home
그것에있을 때 시도하고로드 http://localhost:3000/pages/photo_list.xml
합니다. 홈페이지에있을 때 올바른 파일을로드합니다.
해당 줄을 다음과 같이 변경하십시오.
flashvars.xml_file = "/photo_list.xml";
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다