Skip to content

Commit cda9fe9

Browse files
committed
prepare jfinal 1.5
1 parent 223f5fc commit cda9fe9

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

src/com/jfinal/core/ActionHandler.java

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,23 @@ public final void handle(String target, HttpServletRequest request, HttpServletR
9999
}
100100
catch (ActionException e) {
101101
int errorCode = e.getErrorCode();
102-
if (errorCode == 404) {
103-
if (log.isWarnEnabled()) {
104-
String qs = request.getQueryString();
105-
log.warn("404 Not Found: " + (qs == null ? target : target + "?" + qs));
106-
}
107-
e.getErrorRender().setContext(request, response).render();
102+
if (errorCode == 404 && log.isWarnEnabled()) {
103+
String qs = request.getQueryString();
104+
log.warn("404 Not Found: " + (qs == null ? target : target + "?" + qs));
108105
}
109-
else if (errorCode == 401) {
110-
if (log.isWarnEnabled()) {
111-
String qs = request.getQueryString();
112-
log.warn("401 Unauthorized: " + (qs == null ? target : target + "?" + qs));
113-
}
114-
e.getErrorRender().setContext(request, response).render();
106+
else if (errorCode == 401 && log.isWarnEnabled()) {
107+
String qs = request.getQueryString();
108+
log.warn("401 Unauthorized: " + (qs == null ? target : target + "?" + qs));
115109
}
116-
else if (errorCode == 403) {
117-
if (log.isWarnEnabled()) {
118-
String qs = request.getQueryString();
119-
log.warn("403 Forbidden: " + (qs == null ? target : target + "?" + qs));
120-
}
121-
e.getErrorRender().setContext(request, response).render();
110+
else if (errorCode == 403 && log.isWarnEnabled()) {
111+
String qs = request.getQueryString();
112+
log.warn("403 Forbidden: " + (qs == null ? target : target + "?" + qs));
122113
}
123-
else {
124-
if (log.isErrorEnabled()) {
125-
String qs = request.getQueryString();
126-
log.error(qs == null ? target : target + "?" + qs, e);
127-
}
128-
e.getErrorRender().setContext(request, response).render();
114+
else if (log.isErrorEnabled()) {
115+
String qs = request.getQueryString();
116+
log.error(qs == null ? target : target + "?" + qs, e);
129117
}
118+
e.getErrorRender().setContext(request, response).render();
130119
}
131120
catch (Exception e) {
132121
if (log.isErrorEnabled()) {

src/com/jfinal/core/Const.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public interface Const {
2626

27-
String JFINAL_VERSION = "1.4";
27+
String JFINAL_VERSION = "1.5";
2828

2929
ViewType DEFAULT_VIEW_TYPE = ViewType.FREE_MARKER;
3030

src/com/jfinal/core/Controller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public Integer getAttrForInt(String name) {
204204
}
205205

206206
private Integer toInt(String value, Integer defaultValue) {
207-
if (value == null)
207+
if (value == null || "".equals(value.trim()))
208208
return defaultValue;
209209
if (value.startsWith("N") || value.startsWith("n"))
210210
return -Integer.parseInt(value.substring(1));
@@ -230,7 +230,7 @@ public Integer getParaToInt(String name, Integer defaultValue) {
230230
}
231231

232232
private Long toLong(String value, Long defaultValue) {
233-
if (value == null)
233+
if (value == null || "".equals(value.trim()))
234234
return defaultValue;
235235
if (value.startsWith("N") || value.startsWith("n"))
236236
return -Long.parseLong(value.substring(1));

src/com/jfinal/plugin/ehcache/EvictInterceptor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import com.jfinal.aop.Interceptor;
2020
import com.jfinal.core.ActionInvocation;
21-
import com.jfinal.core.Controller;
2221

2322
/**
2423
* EvictInterceptor.
@@ -28,16 +27,15 @@ public class EvictInterceptor implements Interceptor {
2827
final public void intercept(ActionInvocation ai) {
2928
ai.invoke();
3029

31-
String cacheName = buildCacheName(ai, ai.getController());
32-
CacheKit.removeAll(cacheName);
30+
CacheKit.removeAll(buildCacheName(ai));
3331
}
3432

35-
private String buildCacheName(ActionInvocation ai, Controller controller) {
33+
private String buildCacheName(ActionInvocation ai) {
3634
CacheName cacheName = ai.getMethod().getAnnotation(CacheName.class);
3735
if (cacheName != null)
3836
return cacheName.value();
3937

40-
cacheName = controller.getClass().getAnnotation(CacheName.class);
38+
cacheName = ai.getController().getClass().getAnnotation(CacheName.class);
4139
if (cacheName == null)
4240
throw new RuntimeException("EvictInterceptor need CacheName annotation in controller.");
4341
return cacheName.value();

src/com/jfinal/validate/Validator.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.jfinal.validate;
1818

19+
import java.lang.reflect.Method;
1920
import java.net.MalformedURLException;
2021
import java.net.URL;
2122
import java.text.ParseException;
@@ -98,6 +99,20 @@ protected String getControllerKey() {
9899
return invocation.getControllerKey();
99100
}
100101

102+
/**
103+
* Return the method of this action.
104+
*/
105+
protected Method getActionMethod() {
106+
return invocation.getMethod();
107+
}
108+
109+
/**
110+
* Return view path of this controller.
111+
*/
112+
protected String getViewPath() {
113+
return invocation.getViewPath();
114+
}
115+
101116
/**
102117
* Validate Required.
103118
*/

0 commit comments

Comments
 (0)