0

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.

Jeetu Verma
  • 199
  • 1
  • 5
  • 19
  • Hi mate and welcome to Stackoverflow! :) You should add some relevant code to your post, in case of your link gets broken. So, that you'll ensure the availability of your code / content for future viewers. – Littm Oct 04 '12 at 09:26

3 Answers3

0

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

Umesh Awasthi
  • 23,407
  • 37
  • 132
  • 204
  • thanx for the suggestion, But can you tell which jar file i have add for Tiles controller (preparer) BaseContoller class? – Jeetu Verma Oct 04 '12 at 09:29
0

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.

PbxMan
  • 7,525
  • 1
  • 36
  • 40
  • 1
    To be fair, you're looking at S2 docs from six years ago--better to reference relevant documentation. – Dave Newton Oct 04 '12 at 13:33
  • @DaveNewton Thnx sir, I am new to Struts 2 ,i am looking to use more struts 2 concept.Can you suggest me any link for latest version. – Jeetu Verma Oct 04 '12 at 18:42
0

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;
    }

}
Dave Newton
  • 158,873
  • 26
  • 254
  • 302