here is my test: TestAspect
@Component
@Aspect
public class TestAspect {
@Before(value = "@annotation(testAnnotation)", argNames = "testAnnotation")
public void test(TestAnnotation testAnnotation) throws RuntimeException {
throw new RuntimeException("runtime exception");
}
}
TestAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface TestAnnotation {
}
TestAction
@Controller
@Result(name = ActionSupport.SUCCESS, type = "json")
public class TestAction extends ActionSupport {
private static final long serialVersionUID = 2680952388896234662L;
@TestAnnotation
public String execute() {
return SUCCESS;
}
}
Strust2 xml
<package name="default" extends="convention-default,json-default">
<interceptors>
<interceptor-stack name="mydefault">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="json">
<param name="ignoreHierarchy">false</param>
<param name="excludeNullProperties">true</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="mydefault" />
<global-results>
<result name="error" type="redirect">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping
exception="java.lang.RuntimeException"
result="error" />
</global-exception-mappings>
</package>
if accessing test.action with ajax(jQuery),the error.jsp is returned in json type. How to make the browser redirect to the error.jsp.
Please advise.
Thanks a lot!!