小编tut*_*ity的帖子

springboot嵌入式tomcat和tomcat-embed-jasper

我有时会在pom.xml中看到以下声明......

   <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    ....
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,spring-boot-starter-web被声明为tomcat-embed-jasper.

是不是spring-boot-starter-web已经有嵌入式tomcat?为什么有些开发人员仍然使用boot-starter-web声明tomcat-embed-jasper?或者有什么理由吗?

java tomcat spring-boot

8
推荐指数
1
解决办法
2万
查看次数

重写在祖父母的构造函数中调用的祖父母的虚拟方法

我的 C++ 代码遇到问题..

class GrandParent {
public:
    GrandParent() 
    { 
        printMe(); 
    }

    virtual void printMe() 
    {
        std::cout << "GrandParent: printme" << std::endl;
    }
}

class Parent : public GrandParent {
public:
    Parent(){}
    virtual void printMe()
    {
         std::cout << "Parent: printMe!" << std::endl;
    }
}

class Child : public Parent {
public:
    Child(){}

    void printMe()
    {
         std::cout << "Child: printMe!" << std::endl;
    }
}

int main()
{
     Child *p = new Child();
     delete p;
}
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,它会打印“GrandParent:printMe”。我的目标是打印“Child: printMe!”。重写 printMe 是否有问题?

c++ inheritance

5
推荐指数
1
解决办法
3703
查看次数

Java侦听器方法参数

我正在为Android游戏项目编写此代码:

public class GameActivity extends Activity implements OnClickListener {

    Button b1 = null;
    Button b2 = null;   

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        b1 = new Button(this);
        b2 = new Button(this);

        b1.setOnClickListener(this);
        b2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        // how parameter "v" got its value.,
        // and where it was initialized???
    }
}
Run Code Online (Sandbox Code Playgroud)

我注意到onClick(View v)onClickListener 的方法,并想问一下参数"View v"在哪里初始化?我知道它包含了点击视图的参考,但它在哪里以及如何获得它的价值?

同样的问题:

public void actionPerformed(ActionEvent e){
    // where/how it initialized "e" ??
}
Run Code Online (Sandbox Code Playgroud)

java android

1
推荐指数
1
解决办法
117
查看次数

标签 统计

java ×2

android ×1

c++ ×1

inheritance ×1

spring-boot ×1

tomcat ×1