invocation拦截setAttr出错(重复了)
一、页面拦截已经配置
/**配置全局拦截器*/
public void configInterceptor(Interceptors me) {
me.add(new ViewInterceptor());// View 页面 拦截
}
二、拦截器ViewInterceptor.java程序
public class ViewInterceptor implements Interceptor {
@Override
public void intercept(Invocation inv) {
seo(inv);//SEO
inv.invoke();
}
private void seo(Invocation inv) {
Controller controller = inv.getController();
String path = inv.getActionKey();
String uri = controller.getRequest().getRequestURI();
Seo seo = new SeoService().getByPagePath(path, uri);
controller.setAttr("seo", seo);
}
三、Controller中提取后,重复
public class PlantController extends Controller{
/*beging--重置SEO*/
Seo seo = getAttr("seo");
if(seo!=null){
seo.setTitle(plant.getTitle()+"_"+seo.getTitle());
reeshi_seo.setKeywords(seo.getKeywords()+","+plant.getCompany());
seo.setDescription(seo.getDescription()+"。"+plant.getTitle()+","+plant.getCompany());
setAttr("seo", seo);
} }
/*end--重置SEO*/
}
四、render后页面出现的问题