LicenseCheckBoxAction.java:Запрашиваемый список ключ 'лицензия' не может быть решена
import java.util.ArrayList;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
public class LicenseCheckBoxAction extends ActionSupport{
private List<String> license;
private String yourLicense;
public String LicenseCheckBoxAction() {
license = new ArrayList<String>();
license.add("red");
license.add("yellow");
license.add("blue");
license.add("green");
return NONE;
}
public String execute() {
return SUCCESS;
}
public List<String> getLicense() {
return license;
}
public void setLicense(List<String> license) {
this.license = license;
}
public String getYourLicense() {
return yourLicense;
}
public void setYourLicense(String yourLicense) {
this.yourLicense = yourLicense;
}
public String[] getDefaultLicense() {
return new String[] { "red", "green" };
}
public void setYourColor(String yourLicense) {
this.yourLicense = yourLicense;
System.out.println(yourLicense);
}
public String display() {
license = new ArrayList<String>();
license.add("red");
license.add("yellow");
license.add("blue");
license.add("green");
return NONE;
}
}
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 name="myPack" extends="struts-default">
<action name="eventInsertAction" class="com.ca.actions.EventInsertAction">
<result name="success">Success.jsp</result>
<result name="error">Error.jsp</result>
</action>
<action name="checkboxListing" class="com.ca.actions.LicenseCheckBoxAction"
method="LicenseCheckBoxAction">
<result name="none">create_event.jsp</result>
</action>
<action name="LicenseCheckBoxAction"
class="com.ca.actions.LicenseCheckBoxAction">
<result name="success">Success.jsp</result>
</action>
</package>
</struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>staff_struts</display-name>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
create_event.jsp Выпуск Лицензии
Исключение
HTTP Status 500 - tag 'checkboxlist', field 'list', name 'yourLicense': The
requested list key 'license' could not be resolved as a
collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
type Exception report
message tag 'checkboxlist', field 'list', name 'yourLicense': The requested list key 'license' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: tag 'checkboxlist', field 'list', name 'yourLicense': The requested list key 'license' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:591)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
root cause
tag 'checkboxlist', field 'list', name 'yourLicense': The requested list key 'license' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
org.apache.struts2.components.Component.fieldError(Component.java:257)
org.apache.struts2.components.Component.findValue(Component.java:350)
org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:82)
org.apache.struts2.components.CheckboxList.evaluateExtraParams(CheckboxList.java:67)
org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:893)
org.apache.struts2.components.UIBean.end(UIBean.java:535)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
org.apache.jsp.create_005fevent_jsp._jspx_meth_s_005fcheckboxlist_005f0(create_005fevent_jsp.java:734)
org.apache.jsp.create_005fevent_jsp._jspx_meth_s_005fform_005f1(create_005fevent_jsp.java:693)
org.apache.jsp.create_005fevent_jsp._jspService(create_005fevent_jsp.java:247)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.33 logs.
Apache Tomcat/8.0.33
Когда я пытаюсь позвонить в JSP с помощью ссылки http://localhost:9999/ChaitanyaArtsViews/create_event.jsp
я получаю вышеуказанное исключение, но когда я попробуйте вызвать действие, используя http://localhost:9999/ChaitanyaArtsViews/checkboxListing.action
, отображается JSP. Как я могу вызвать JSP напрямую без имени действия, поскольку JSP связан с другим, и, следовательно, его следует вызывать вместо действия?
Никогда не вызывайте jsp напрямую. Действие -> JSP. –
Я вызываю jsp через одну из ссылок на мою домашнюю страницу jsp, в основном запускаю весь проект, но получаю исключение, однако, когда я вызываю прямо через ссылку действия, я не получаю ошибку. –