私は Struts2 を初めて使用し、実際に Struts2 を使用して学習します。リクエストパラメーターをリストにマップし、同時にパラメーターをデフォルトタイプの文字列から倍精度または整数に変換しようとする本の例を見つけました。リストにタイプ情報がないことを前提としています(Java 5より前のように)。例外が発生しています。
ログイン.jsp
<s:form action="LoginAction">
<s:textfield name="username" label="Username"></s:textfield>
<s:password name="password" label="Password"></s:password>
<s:textfield name="age" label="Age"></s:textfield>
<s:textfield name="name" label="First Name"></s:textfield>
<s:textfield name="name" label="Second Name"></s:textfield>
<s:textfield name="name" label="Last Name"></s:textfield>
<s:submit value="Login"></s:submit>
</s:form>
ログインアクション
package org.shammu.actions;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class LoginAction extends ActionSupport{
private String username;
private String password;
private int age;
private List name;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List getName() {
return name;
}
public void setName(List name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
スタックトレース
Sep 3, 2013 11:06:22 AM
com.opensymphony.xwork2.conversion.impl.DefaultConversionFileProcessor error
SEVERE: Problem loading properties for org.shammu.actions.LoginAction
java.lang.InstantiationException: java.lang.Double
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:131)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:162)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151)
at com.opensymphony.xwork2.conversion.impl.DefaultTypeConverterCreator.
createTypeConverter(DefaultTypeConverterCreator.java:23)
at com.opensymphony.xwork2.conversion.impl.DefaultConversionFileProcessor.
process(DefaultConversionFileProcessor.java:68)
at com.opensymphony.xwork2.conversion.impl.XWorkConverter.addConverterMapping
(XWorkConverter.java:485)
at com.opensymphony.xwork2.conversion.impl.XWorkConverter.buildConverterMapping
(XWorkConverter.java:549)
at com.opensymphony.xwork2.conversion.impl.XWorkConverter.getConverter
(XWorkConverter.java:417)
at com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue
(XWorkConverter.java:282)
at com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue
(OgnlTypeConverterWrapper.java:39)
at ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:1080)
at ognl.OgnlRuntime.getConvertedTypes(OgnlRuntime.java:1097)
at ognl.OgnlRuntime.getConvertedMethodAndArgs(OgnlRuntime.java:1123)
at ognl.OgnlRuntime.getAppropriateMethod(OgnlRuntime.java:1209)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1223)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1494)
at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty
(ObjectAccessor.java:27)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty
(CompoundRootAccessor.java:78)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2332)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:234)
at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:183)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:170)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter
(OgnlValueStack.java:148)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters
(ParametersInterceptor.java:318)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept
(ParametersInterceptor.java:231)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept
(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept
(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept
(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept
(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept
(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept
(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept
(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept
(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept
(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept
(I18nInterceptor.java:161)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept
(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept
(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept
(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction
(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter
(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process
(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
ここで、アクション クラスの同じフォルダーに配置された変換ファイルはLoginAction-conversion.properties has a single lineElement-name=java.lang.Double
です。助けて