2010-05-12 1 views
0

struts2, jsp 및 표준 서블릿으로 작성된 간단한 웹 응용 프로그램을 업데이트하려고합니다. URL을 특정 작업으로 리디렉션하려고하지만 올바르게 작동하지 않는 것처럼 보입니다. 예를 들어, 올바른 URL이 : 여기 struts 액션 및 리디렉션 문제가 있습니다.

http://localhost:8080/theapp/lookup/search.action 

내 web.xml에 있습니다 :

<?xml version="1.0" encoding="UTF-8" ?> 

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration  
2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> 
: 여기

<?xml version="1.0" encoding="ISO-8859-1"?> 
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
        "http://java.sun.com/dtd/web-app_2_3.dtd"><web-app> 
<display-name>theapp</display-name> 

<filter> 
    <filter-name>struts2</filter-name> 
    <filter-class> 
     org.apache.struts2.dispatcher.FilterDispatcher 
    </filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>struts2</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

<listener> 
    <listener-class> 
     org.springframework.web.context.ContextLoaderListener 
    </listener-class> 
</listener> 

그리고 나의 struts.xml입니다

지수

<default-action-ref name="search" /> 

<action name="search" method="search" class="com.theapp.SearchAction" > 
    <result>index.jsp</result> 
    <result name="input" >index.jsp</result> 
    <result name="error" type="redirect">site_locator_mobile/error.action</result> 
</action> 

여기서 문제는 내가 위에서 올바른 URL을 지정하지 않은 경우, 나는 단지의 index.jsp 파일을 얻을 수 있다는 것입니다하지만 없이 속성. jsp는 정보가 서블릿에 포함되어 있기 때문에 처리됩니다.

누군가가 방금 입력 한 경우입니다 싶습니다 무엇 :

http://localhost:8080/theapp/lookup/ 

그들로 이동하는 것보다 :

http://localhost:8080/theapp/lookup/search.action 

감사

+0

음 .. 같은 코드 블록에 모두 있기 때문에 위의 게시물에서 xml을 수정하는 방법을 잘 모르겠습니다. – Casey

답변

0

어쩌면 당신은 환영으로 서블릿을 지정할 수 있습니다 파일 :

<welcome-file-list> 
<welcome-file>search.action<welcom-file> 
<welcome-file-list> 

참고 : 어떤 사람들은 이것이 작동하려면 search.action이라는 파일이 실제로 존재해야한다고보고합니다.

또 다른 옵션은 index.jspsearch.action로 리디렉션 다른 결과 JSP를 사용하는 것입니다 :

<% response.sendRedirect("search.action"); %> 

편집 : 직접 /theapp/lookup//theapp/lookup/search.action에 대한 요청을 리디렉션 web.xml에 필터 매핑 지시문을 추가 할 수도 있습니다

더 복잡한 것처럼 보입니다.

+0

환영 파일 접근 방식은 전체 응용 프로그램에서 리디렉션되는 것처럼 나를 위해 작동하지 않습니다. index.jsp에는 사용할 필요가있는 항목이 있으며, 단지 자리 표시자가 아닙니다. 현재 파일의 이름을 다른 것으로 바꾸고 index.jsp를 적절한 동작으로 리디렉션 할 수 있다고 가정합니다. – Casey

0

바보처럼 들리 겠지만 struts.xml 파일의 전체 내용을 게시 할 수 있습니까? 네임 스페이스를 struts xml 파일에 추가 했습니까? myApp/lookup/someAction.action을 찾으려고합니다. 나는 당신이 당신의 패키지를 위해 정의 된 이름 공간을 가져야한다고 생각한다.