-
struts2中set集合的自定义类型转换5
Action如下:
public class LoginAction extends ActionSupport
{
private Set users;
private Date birth;
//user属性的setter和getter方法
public void setUsers(Set users)
{
this.users = users;
}
public Set getUsers()
{
return this.users;
}
//birth属性的setter和getter方法
public void setBirth(Date birth)
{
this.birth = birth;
}
public Date getBirth()
{
return this.birth;
}
//没有提供execute()方法,
//将直接使用ActionSupport的execute()方法
}
LoginAction-conversion.properties
#指定users属性的类型转换器是UserConverter
users=qlj1.setSupport.UserConverter
#指定users集合属性里集合元素的索引属性是name
KeyProperty_users=name
实现类型转换
public class UserConverter extends StrutsTypeConverter
{
public Object convertFromString(Map context
, String[] values, Class toClass)
{
Set result = new HashSet();
for (int i = 0; i < values.length ; i++ )
{
try {
//创建一个User实例
User user = new User();
//只处理请求参数数组第一个数组元素,
//并将该字符串以英文逗号分割成两个字符串
String[] userValues = values[i].split(",");
//为User实例的属性赋值
user.setName(userValues[0]);
user.setPass(userValues[1]);
//将User实例添加到Set集合中
result.add(user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return result;
}
public String convertToString(Map context, Object o)
{
//如果待转换对象的类型是Set
if (o.getClass() == Set.class)
{
Set users = (Set)o;
String result = "[";
for (Object obj : users )
{
User user = (User)obj;
result += "<" + user.getName()
+ "," + user.getPass() + ">";
}
return result + "]";
}
else
{
return "";
}
}
}
转换的目标类型
public class User
{
private String name;
private String pass;
//name属性的setter和getter方法
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return this.name;
}
//pass属性的setter和getter方法
public void setPass(String pass)
{
this.pass = pass;
}
public String getPass()
{
return this.pass;
}
public boolean equals(Object obj)
{
//待比较的两个对象是同一个对象,直接返回true
if(this == obj)
{
return true;
}
//只有当obj是User对象
if (obj != null && obj.getClass() == User.class)
{
User user = (User)obj;
//两个对象的name属性相等即认为二者相等。
if (this.getName().equals(user.getName()))
{
return true;
}
}
return false;
}
//根据name属性来计算hashCode。
public int hashCode()
{
return name.hashCode();
}
}
输入界面
input.jsp
<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Set属性的类型转换</title>
</head>
<body>
<h3>Set属性的类型转换</h3>
<s:form action="setLogin">
<s:textfield name="users" label="第一个用户信息"/>
<s:textfield name="users" label="第二个用户信息"/>
<s:textfield name="birth" label="用户生日"/>
<tr>
<td colspan="2"><s:submit value="转换" theme="simple"/>
<s:reset value="重填" theme="simple"/></td>
</tr>
</s:form>
</body>
</html>
输出界面
welcom.jsp
<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>转换成功</title>
</head>
<body>
<s:debug></s:debug>
<s:property value="tip"/><br/>
<s:property value="users"/><br/>
用户1的用户名为:<s:property value="users(1).name"/><br/>
用户1的密码为:<s:property value="users(1).pass"/><br/>
用户2的用户名为:<s:property value="users(2).name"/><br/>
用户2的密码为:<s:property value="users(2).pass"/><br/>
生日为:<s:property value="birth"/><br/>
</body>
</html>
怎么在welcome界面取不到,但users属性的值已经在Value Stack里面了,请问给位怎么取里面的值
问题补充:为什么在welcome.jsp里加个<s:debug/>会产生如下异常
严重: An unexpected exception occurred
java.lang.NullPointerException
at com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:122)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:81)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1349)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1325)
at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.callMethod(CompoundRootAccessor.java:232)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1349)
at ognl.ASTMethod.getValueBody(ASTMethod.java:90)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.ASTChain.getValueBody(ASTChain.java:141)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.Ognl.getValue(Ognl.java:494)
at com.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:217)
at com.opensymphony.xwork2.ognl.OgnlValueStack.getValue(OgnlValueStack.java:342)
at com.opensymphony.xwork2.ognl.OgnlValueStack.tryFindValue(OgnlValueStack.java:331)
at com.opensymphony.xwork2.ognl.OgnlValueStack.tryFindValueWhenExpressionIsNotNull(OgnlValueStack.java:307)
at com.opensymphony.xwork2.ognl.OgnlValueStack.findValue(OgnlValueStack.java:293)
at org.apache.struts2.components.Property.start(Property.java:162)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
at org.apache.jsp.jsp._1.setWelcome_jsp._jspx_meth_s_005fproperty_005f2(setWelcome_jsp.java:183)
at org.apache.jsp.jsp._1.setWelcome_jsp._jspService(setWelcome_jsp.java:82)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:159)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
2013-1-3 23:43:39 com.opensymphony.xwork2.util.logging.jdk.JdkLogger error
严重: An unexpected exception occurred
java.lang.NullPointerException
at com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:122)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:81)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1349)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1325)
at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.callMethod(CompoundRootAccessor.java:232)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1349)
at ognl.ASTMethod.getValueBody(ASTMethod.java:90)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.ASTChain.getValueBody(ASTChain.java:141)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.Ognl.getValue(Ognl.java:494)
at com.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:217)
at com.opensymphony.xwork2.ognl.OgnlValueStack.getValue(OgnlValueStack.java:342)
at com.opensymphony.xwork2.ognl.OgnlValueStack.tryFindValue(OgnlValueStack.java:331)
at com.opensymphony.xwork2.ognl.OgnlValueStack.tryFindValueWhenExpressionIsNotNull(OgnlValueStack.java:307)
at com.opensymphony.xwork2.ognl.OgnlValueStack.findValue(OgnlValueStack.java:293)
at org.apache.struts2.components.Property.start(Property.java:162)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
at org.apache.jsp.jsp._1.setWelcome_jsp._jspx_meth_s_005fproperty_005f4(setWelcome_jsp.java:221)
at org.apache.jsp.jsp._1.setWelcome_jsp._jspService(setWelcome_jsp.java:92)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:159)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)2013年1月03日 21:50
目前还没有答案
相关推荐
Struts2还支持集合类型转换的高级特性,如指定集合元素的类型,以及为Set集合指定索引属性,如在struts2_5_5_1和struts2_5_5_2案例中演示。 在类型转换过程中,错误处理是必不可少的。Struts2默认配置了一个名为...
在Struts2中,可以使用迭代器(`<s:iterator>`标签)配合动态属性(`name`属性使用表达式语言)实现批量保存对象。例如,创建一个包含学生列表的Action属性,并在JSP页面中使用迭代器为每个学生创建输入字段。然后,...
7.1.3 Set集合类型数据类型转换功能 141 7.2 类型转换发生异常处理方案 144 7.2.1 Struts2自带异常提示 145 7.2.2 Struts2局部异常提示定义属性文件使用介绍 146 7.2.3 Struts2全局异常提示定义属性文件使用介绍 147...
5.4.3 配置框架使用自定义转换器 103 5.5 小结 106 第三部分 构建视图——标签和结果 第6章 构建视图——标签 108 6.1 入门 108 6.1.1 ActionContext和OGNL 109 6.1.2 虚拟对象ValueStack 111 6.2 Struts 2标签概要...
在Struts2中,类型转换是自动进行的,旨在帮助开发者处理请求参数与Action类属性之间的类型匹配问题。文档中的内容主要涉及到Struts2.0的类型转换机制,特别是对于自定义类型转换器的使用。 首先,Struts2.0内置了...
本篇文章将深入探讨如何在Struts2中实现从复杂实体对象到页面参数的有效转换,以提升开发效率和代码的可维护性。在实际项目开发中,我们经常需要将用户在页面上填写的数据映射到后台的实体对象,Struts2的...
以下是Struts2的一些核心知识点,掌握这些内容能够帮助你在面试中表现出色。 1. **MVC模式的优势**: MVC模式将应用程序分为三个层次:视图(View)、模型(Model)和控制器(Controller)。这种分离有利于项目...
- **5.4.4 User集合(Set)属性类型转换器,有多个String需要转换为User类型** - **实现方式**:如果需要将多个字符串转换成User对象集合,应该如何实现。 **5.5 类型转换错误处理** - **实现方式**:当类型转换...
2. **集合属性的类型转换器**: 类似于数组,集合如List或Set也需要进行类型转换。用户输入的数据可能是字符串形式,而我们的模型可能需要List或Set。自定义的集合转换器可以确保数据正确地被解析和填充到集合对象中...
6. **CollectionSupport**和**SetSupport**: 这些部分可能涉及到如何处理不同类型的集合,如List和Set,以及如何在Struts2中有效地进行数据绑定。 7. **ErrorHandle1**: 错误处理是任何Web应用的重要组成部分。这...
本文主要探讨了如何在Struts2中自定义标签并进行数据验证和转换。 首先,一个基本的Action类在Struts2中是核心组件,通常继承自`ActionSupport`类,因为这个基类提供了错误处理和国际化支持。`execute()`方法是...
首先,让我们理解三种在Struts2中传递数据的方法: 1. **Struts2标签库**:Struts2提供了一套丰富的标签库,如`s:textfield`、`s:submit`等,可以直接在JSP页面中使用。这些标签能够帮助开发者轻松地处理表单提交,...
OGNL(Object-Graph Navigation Language)是Struts2中的表达式语言,用于在Action、值栈和视图之间传递数据,支持复杂的对象导航和表达式计算。 十三、Struts2标签: Struts2提供了一系列的标签库,简化了视图层的...
- **概念**:命名空间是Struts2中用于组织Action的一种机制,每个Action可以通过指定的命名空间来访问。 - **路径确定**:命名空间决定了Action的访问路径。默认情况下,命名空间为空,这意味着所有未指定命名空间的...
8. **访问Web元素**:通过实现`SessionAware`接口,Struts2能够注入HttpSession到Action中的Map类型变量,从而方便访问Session数据。 9. **Value Stack**:Value Stack中的值存储在request作用域中,Action中的变量...
自定义标签可以与Spring MVC、Struts2等框架集成,提供更丰富的功能。 通过上述内容,我们了解了Freemarker自定义标签的基本概念、创建与使用方法,以及如何在实际项目中发挥作用。自定义标签极大地增强了...
根据提供的文件信息,我们可以归纳出以下关于Struts2中OGNL(Object-Graph Navigation Language)的知识点: ### 1. 引言与简介 OGNL 是一种强大的表达式语言,它允许开发人员通过简洁的语法来导航 Java 对象。...
- 在Struts1.x中使用Freemarker,可能需要处理一些特定的类型转换问题,例如日期、自定义对象等。 通过以上知识点的介绍,我们对Struts1.x整合Freemarker有了全面的理解。在实际开发中,这样的整合可以显著提高...