Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.IllegalArgumentException:setAttribute:名称为的不可序列化属性_Java_Spring Mvc_Serialization - Fatal编程技术网

java.lang.IllegalArgumentException:setAttribute:名称为的不可序列化属性

java.lang.IllegalArgumentException:setAttribute:名称为的不可序列化属性,java,spring-mvc,serialization,Java,Spring Mvc,Serialization,我是SpringMVC新手,正在尝试编写基于web的应用程序…出现以下错误 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: setAttribute: 名称为的不可序列化属性 InventoryMgmtSpring.web.PriceIncreaseFormControl

我是SpringMVC新手,正在尝试编写基于web的应用程序…出现以下错误

 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: setAttribute:
名称为的不可序列化属性 InventoryMgmtSpring.web.PriceIncreaseFormController.FORM.priceIncrease 根本原因

 java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute with name InventoryMgmtSpring.web.PriceIncreaseFormController.FORM.priceIncrease
app-servelet.xml中的代码片段

  <bean name="/priceincrease.htm"   class="InventoryMgmtSpring.web.PriceIncreaseFormController">
    <property name="sessionForm" value="true"/>
    <property name="commandName" value="priceIncrease"/>
    <property name="commandClass" value="InventoryMgmtSpring.service.PriceIncrease"/>
    <property name="validator">
        <bean class="InventoryMgmtSpring.service.PriceIncreaseValidator"/>
    </property>
    <property name="formView" value="priceincrease.htm"/>
    <property name="successView" value="hello.htm"/>
    <property name="productManager" ref="productManager"/>
</bean> 
来自PriceIncrease的代码片段 =------------------------------

 public class PriceIncrease {

/** Logger for this class and subclasses */

protected  final Log logger = LogFactory.getLog(getClass());
private int percentage ;
public void setPercentage(int i)
{
    this.percentage=i;
    logger.info("Percentage set to" + i);
}
public int getPercentage()
{
    return percentage;
  }
 }

首先,我会避免在PriceIncrease中使用记录器,并将PriceIncrease更像是一个POJO。很难确定问题的根本原因到底是什么,但我相信问题可能是在尝试序列化记录器时出现的。尝试删除记录器或在日志变量之前添加关键字transient


我希望这会有所帮助。

首先,我会避免在价格上涨时使用记录器,并将价格上涨更像是一个POJO。很难确定问题的根本原因到底是什么,但我相信问题可能是在尝试序列化记录器时出现的。尝试删除记录器或在日志变量之前添加关键字transient


我希望它能有所帮助。

错误告诉您
表单的
priceIncrease
属性
PriceIncreaseFormController
priceIncrease属性属于不实现
java.io.Serializable
的类型。我在您发布的代码中没有看到任何
表单
属性,因此发布的代码已被修改,或者该属性在继承树中更高(
SimpleFormController
).

错误告诉您
PriceIncreaseFormController
FORM
属性的
priceIncrease
属性属于不实现
java.io.Serializable
的类型。我在您发布的代码中没有看到任何
表单
属性,因此发布的代码已被修改,或者该属性在继承树中更高(
SimpleFormController
)。

谢谢大家。我发现了错误

1) 类PriceIncrease实现可序列化

2) 该值必须更改为“priceincrease”,而不是“priceincrease.htm”


代码运行良好。再次感谢您的帮助

谢谢大家。我发现了错误

1) 类PriceIncrease实现可序列化

2) 该值必须更改为“priceincrease”,而不是“priceincrease.htm”


代码运行良好。再次感谢您的帮助

还没有开始工作。课堂上需要的任何修改???尚未生效。课堂上需要修改吗???
 public class PriceIncrease {

/** Logger for this class and subclasses */

protected  final Log logger = LogFactory.getLog(getClass());
private int percentage ;
public void setPercentage(int i)
{
    this.percentage=i;
    logger.info("Percentage set to" + i);
}
public int getPercentage()
{
    return percentage;
  }
 }