0
스프링 처리기에 사용자 정의 속성 편집기를 추가했습니다. 그리고 jspx 페이지의 속성 중 하나와 작동하지만 다른 것들은 그렇지 않습니다. 단지 toString of Money 클래스 만 출력합니다. 속성 편집기가 Spring 사용자 정의 편집기
public String getAsText() {
String textValue = null;
if (this.getValue() != null) {
Money money = (Money) this.getValue();
System.out.println("getAsText money: " + money);
textValue = String.valueOf(money.getAmount());
System.out.println("textValue: " + textValue);
}
return textValue;
}
같은 시스템을 보이는
<cat:input type="text" uiid="amount" bindpath="form.pack.amount"/>€
돈 :로
는그리고 돈 유형으로하여 jspx 속성
public void initBinder(final HttpServletRequest request, final ServletRequestDataBinder binder) {
binder.registerCustomEditor(Money.class, new MoneyPropertyEditor());
}
참조 그래서
getAsText money: Money: Amount: 0.7, AsCents: 70
textValue: 0.7
- 속성 편집기가 작동하고 호출됩니다. 디. 그러나 입력은 여전히 보유하고 있습니다. 문자열 표현 : money: Money: Amount: 0.7, AsCents: 70
아니요 0.7
출력 맞춤 속성 편집기를 사용하려면 다른 구성을 사용해야합니까?
데이터 바인딩을 시도하는 객체에 'Money' 유형의 다른 필드가 있습니까? –
네, 그들은 같은 방식으로' €' –