Skip to content

Commit

Permalink
1.6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
noear committed Dec 20, 2021
1 parent 84a563b commit e252d4d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion _test/src/main/java/webapp/demo2_mvc/ParamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public UserModel test_h1(Context ctx, UserModel model) throws Throwable {

//支持时间参数(要加XParam指定格式)
@Mapping("date")
public Object test_h2(Context ctx, @Param(format = "yyyy-MM-dd") Date date, Date date2) throws Exception{
public Object test_h2(Context ctx, Date date, Date date2) throws Exception{
return date + " # " + date2;
}

Expand Down
4 changes: 0 additions & 4 deletions solon/src/main/java/org/noear/solon/annotation/Param.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
* */
@Alias("value")
String name() default "";
/**
* 格式(主要为日期之类的服务)
* */
String format() default "";
/**
* 必须的(只做标识,不做检查)
* */
Expand Down
18 changes: 4 additions & 14 deletions solon/src/main/java/org/noear/solon/core/util/ConvertUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ConvertUtil {
* @param val 值
* @param ctx 通用上下文
*/
public static Object to(AnnotatedElement element, Class<?> type, String key, String val, Context ctx) throws ClassCastException {
public static Object to(AnnotatedElement element, Class<?> type, String key, String val, Context ctx) throws ClassCastException {
if (String.class == (type)) {
return val;
}
Expand All @@ -44,19 +44,9 @@ public static Object to(AnnotatedElement element, Class<?> type, String key, Str
Object rst = null;

if (rst == null && Date.class == type) {
Param xd = null;

if (element != null) {
xd = element.getAnnotation(Param.class);
}

try {
if (xd != null && Utils.isEmpty(xd.format()) == false) {
rst = new SimpleDateFormat(xd.format()).parse(val);
} else {
rst = DateUtil.parse(val);
}
}catch (ParseException e){
rst = DateUtil.parse(val);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
Expand All @@ -71,7 +61,7 @@ public static Object to(AnnotatedElement element, Class<?> type, String key, Str
}

//todo:可能有兼容问题("?aaa=1,2&aaa=3,4,5,6",只传第一部份时就麻烦了)
if(ary.length == 1){
if (ary.length == 1) {
ary = val.split(",");
}

Expand Down

0 comments on commit e252d4d

Please sign in to comment.