以下是一个使用 Struts 拦截 JSP 页面跳转的简单实例:
1. 我们需要在 `struts.xml` 文件中定义一个拦截器。假设拦截器的名称为 `MyInterceptor`:
```xml
```
2. 接下来,创建 `MyInterceptor` 类,继承自 `com.opensymphony.xwork2.interceptor.MethodFilterInterceptor`。在拦截器中重写 `intercept` 方法:
```java
package com.example;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.opensymphony.xwork2.ActionInvocation;
public class MyInterceptor extends MethodFilterInterceptor {
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
// 检查是否需要跳转到 JSP 页面
if (invocation.getAction().getClass().getName().contains("