将我们的应用程序从struts 2.3升级到2.5时,我们收到以下错误。
包org.apache.tiles.request不存在
这是我们为执行的方法修改的代码。
package com.myeg.ins.web.control.helper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.apache.tiles.Attribute;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.context.TilesRequestContextHolder;
import org.apache.tiles.preparer.PreparerException;
import org.apache.tiles.preparer.ViewPreparer;
import org.apache.tiles.request.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MenuPreparer implements ViewPreparer
{
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
protected Logger logger = LoggerFactory.getLogger(this.getClass());
TilesContainer tileContainer = TilesAccess.getCurrentContainer((Request) request);
/*-----previous code while using tiles 2.0
public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) throws PreparerException
{
String ins=(String)session.getAttribute("insComp");
logger.info("In Preparer Ins company is::::::"+ins);
attributeContext.putAttribute("breadcrumbshead", new Attribute(ins));
}*/
@Override
public void execute(Request tileContainer, AttributeContext attributeContext) {
// TODO Auto-generated method stub
String ins=(String)session.getAttribute("insComp");
logger.info("In Preparer Ins company is::::::"+ins);
attributeContext.putAttribute("breadcrumbshead", new Attribute(ins));
}
}
答案 0 :(得分:0)
我从未使用过Apache Tile,但由于错误是:
包org.apache.tiles.request不存在
因为它发生在你提到的更新之后。在我看来,你应该为org.apache.tiles.request添加一个新版本。
如果您使用maven来构建应用程序,则应该在pom.xml中将依赖项更改为:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles3-plugin</artifactId>
<version>${version.tiles}</version>
<scope>compile</scope>
</dependency>
您可以在以下链接中阅读有关此内容的更多信息: