,하는 doView()가 I가 링크를 포함하는 간단한 JSP를 표시 할 수있어 WebSphere Portal에 7에서 실행 호출되지 작동하지하는 액션을 호출하고 입력을 받아들이는 다른 JSP를 표시합니다. 그건 잘 작동합니다.스트럿츠 2 포틀릿 - redirectAction 나는 간단한 스트럿츠 2 JSR 286 포틀릿을 만들려고 해요
그러나 redirectAction
을 사용하려고하면 문제가 발생하기 시작합니다. 오류 메시지가 표시되지 않지만 리디렉션이 작동하지 않는 것 같습니다. 포틀릿에는 빈 페이지가 표시됩니다.
이 디버깅에서 나는 포틀릿 클래스의 doView
메서드가 호출되지 않는다는 것을 알아 차렸는데, 이는 매우 의심스러워 보입니다. 사람이 경험은 WebSphere Portal에 스트럿츠 2 개 포틀릿을 개발하고있는 경우
, 내 설정 파일이 올바른지 확인에 약간의 도움을 주셔서 감사합니다. 내가 놓친 게 있니?
WebSphere Portal 7.0.0.2
WebSphere Application Server 7.0.0.25
RAD 8.0.4
Struts 2.3.14.2
Windows 7
은 portlet.xml :
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app id="com.ibm.demo.jsr286.TopUpPortlet.72594d5fe3"
version="2.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<description xml:lang="EN">Demo JSR 286 Struts Portlet</description>
<portlet-name>Demo Portlet</portlet-name>
<display-name>Demo Portlet</display-name>
<!-- DemoPortlet extends org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher -->
<portlet-class>com.demo.jsr286.DemoPortlet</portlet-class>
<init-param>
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>Demo Portlet</title>
<short-title>DemoPortlet</short-title>
<keywords>Demo Portlet</keywords>
</portlet-info>
</portlet>
<default-namespace>http://JSR286StrutsDemo/</default-namespace>
</portlet-app>
의 web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>JSR 286 Struts Demo</display-name>
<servlet id="Struts2PortletDispatcherServlet">
<servlet-name>Struts2PortletDispatcherServlet</servlet-name>
<servlet-class>org.apache.struts2.portlet.dispatcher.DispatcherServlet</servlet-class>
</servlet>
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.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">
<struts>
<include file="struts-plugin.xml"/>
<package name="view" extends="struts-portlet-default" namespace="/view">
<!-- This action works -->
<action name="index">
<result>/html/view/index.jsp</result>
</action>
<!-- This action works -->
<action name="startDemo">
<result>/html/view/demo.jsp</result>
</action>
<!-- This action does not work -->
<action name="redirectToIndex">
<result type="redirectAction">
<param name="actionName">index</param>
<param name="namespace">/view</param>
<param name="portletMode">view</param>
</result>
</action>
</package>
</struts>
여기
은 세부 사항입니다
* 업데이트 *
문제가 다소 좁혀졌습니다. 액션이 struts 액션이 아닌 파일 위치로 해석되는 것 같습니다. 그래서 "redirectToIndex"액션을 호출하면 "/view/index.action"이라는 페이지를 표시하려고 시도합니다. 해당 경로가있는 파일을 작성하여이 사실을 확인 했으므로 해당 파일의 내용이 포틀릿에 표시됩니다.
는 내가 아마 몇 가지 구성 옵션을 누락 느낌,하지만 난 모르겠어요. 서블릿 필터가 어쩌면? 누구든지 도와 줄 수 있습니까?
그래서 무엇입니까? 리디렉션이 작동하지 않거나 메서드가 호출되지 않습니다? BTW 왜'struts-plugin.xml' 파일을 포함하고 있습니까? –
둘 다 정말입니다. 리디렉션이 작동하지 않는 것이 첫 번째 문제였습니다. 그런 다음 조사 할 때 doView가 호출되지 않는 것으로 나타났습니다. struts-plugin.xml은 struts-portlet-default 패키지가 정의 된 곳이기 때문에 포함하고 있습니다. 그게 맞지 않아? – dgwatson
이미 포함되어 있으므로 직접 포함시킬 필요가 없습니다. 액션 클래스를 사용하여'redirectToIndex' 액션 정의에 클래스 속성을 부여하십시오. –