action class übergibt keine Objekte an die JSP-Klasse mit struts2 in liferay
Ich verwende Struts2 in Liferay, um ein Portlet zu erstellen. Ich habe eine Senden-Schaltfläche, die eine Aktion ausführt. In der Aktionsmethode möchte ich ein privates Feld füllen und an resualt add.jsp übergeben, aber wenn ich dieses Feld ausdrucken möchte add.jsp Der Wert ist null. worin besteht das Problem???!!! was soll ich machen????!
Es gibt keine Fehler oder Ausnahmen beim Ausführen des Servers, beim Erstellen / Bereitstellen und Ausführen ...
hier ist mein Code:
portlet.xml
http: //java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd "version =" 2.0 ">
<description xml:lang="EN">IIN Subject</description>
<portlet-name>MySiteStruts</portlet-name>
<display-name>MySiteStruts</display-name>
<!-- struts portlet class -->
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
<!-- The namespace for the actions configured for view mode -->
<init-param>
<name>viewNamespace</name>
<value>/support</value>
</init-param>
<!-- The default action to invoke in view mode. -->
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>MySiteStruts</title>
<short-title>MySiteStruts</short-title>
<keywords>MySiteStruts</keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
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>
<constant name="struts.devMode" value="true" />
<package namespace="/support" extends="struts-portlet-default,json-default"
name="subjectview">
<interceptors>
<interceptor-stack name="storeStack">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="store">
<param name="operationMode">STORE</param>
</interceptor-ref>
</interceptor-stack>
<interceptor-stack name="retrieveStack">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="store">
<param name="operationMode">RETRIEVE</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<action name="index" >
<result>/html/support/view.jsp</result>
</action>
<action name="addsubjects" class="com.test.actions.PowerAction"
method="navigateToAddSubject">
<result name="success">/html/support/add.jsp</result>
</action>
</package>
</struts>
PowerAction.java
package com.test.actions;
import com.opensymphony.xwork2.ActionSupport;
public class PowerAction extends ActionSupport {
private String testString;
@Override
public String execute() throws Exception {
return "success";
}
public String navigateToAddSubject(){
testString = "test object value!!!!!";
System.out.println(testString);
return SUCCESS;
}
public String getTestString() {
return testString;
}
public void setTestString(String testString) {
this.testString = testString;
}
}
view.jsp
<%@ include file="/html/init.jsp" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:form action="addsubjects" theme="simple">
<s:submit value="submit"/>
</s:
[/code]
[b]add.jsp[/b]
[code]
<%@ include file="/html/init.jsp" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<h1>print str:<br></h1>
<h2><s:property value="%{testString}"/></h2>
Ich benutze sogar value = "testString" in add.jsp, aber das funktioniert nicht.