For example,
@Authority
@RequestMapping(value="/list",method = RequestMethod.POST)
public @ResponseBody String listNewEnterprises(HttpServletRequest request) {
JSONObject json = new JSONObject();
//do something
Object o;
try {
json.put("result", "success");
json.put("value", o);
} catch (JSONException e) {
e.printStackTrace();
}
System.out.println(json);// can print the json value
return json.toString();
}
All work well before adding @Authority, but once added @Authority, the ajax get Null.
My @Authority is used to authorize user's right to access the method, which is intercepted by extending HandlerInterceptorAdapter.
The spring-mvc.xml is configured as:
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<mvc:annotation-driven />
<mvc:interceptors>
<bean class="com.sjd.annotation.AuthorityAnnotationInterceptor"></bean>
</mvc:interceptors>
Aucun commentaire:
Enregistrer un commentaire