سؤال

I am using below code,

http://books.google.co.in/books?id=1rbeG3-jdnoC&pg=PA383&lpg=PA383&dq=BaseController++struts+2+jar+file&source=bl&ots=cYl89RBGnJ&sig=M3kyXKvV5ARK6SysxI8diagRces&hl=en&sa=X&ei=jzttUO-_FoLirAf-r4CQBw&ved=0CCgQ6AEwAQ#v=onepage&q=BaseController%20%20struts%202%20jar%20file&f=false

which i read in Struts 2 in action.But i am unable to import BasceCntoller class. Can anyone tell me which jar file i am missing?

please help me.Thank you in advance.

هل كانت مفيدة؟

المحلول

Well if you have just started with Struts2, i suggest you to download sample applications from Struts2 home page and run them.

these sample apps comes with required jars which should be there in minimum to run Struts2 application.

Alternatively if you can go ahead with maven i will suggest you to create sample Struts2 application with maven and let maven download and provide you all the dependencies you need to run your sample application

نصائح أخرى

I haven't found a BaseController for Struts 2 http://struts.apache.org/2.0.9/struts2-core/apidocs/index.html It looks like a Spring MVC class instead http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/controllers/BaseController.html . I haven't been using this class however it's the spring-webmvc.jar the one that normally contains the interface.

S2iA targets Struts 2.0, a very old version.

In any case:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.preparer.ViewPreparer;

import com.opensymphony.xwork2.util.ValueStack;
import com.strutsschool.db.DB;

public class BaseController implements ViewPreparer {

    private Log log = LogFactory.getLog(this.getClass());
    protected DB db;
    private ValueStack stack;

    public void execute(TilesRequestContext tilesContext,
                        AttributeContext attributeContext) {
        stack = (ValueStack) tilesContext.getRequestScope().get(ServletActionContext.STRUTS_VALUESTACK_KEY);
    }

    public ValueStack getStack() {
        return stack;
    }

    public DB getDb() {
        return db;
    }

    public void setDb(DB db) {
        this.db = db;
    }

}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top