Android-onSaveInstanceState方法啥时候被调用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android-onSaveInstanceState方法啥时候被调用相关的知识,希望对你有一定的参考价值。

  当某个activity变得“容易”被系统销毁时,该activity的onSaveInstanceState就会被执行,除非该activity是被用户主动销毁的,例如当用户按BACK键的时候。 参考技术A 在Honeycomb之前,Activity是不可被杀死了直到它们被暂停了,也就是说onSaveInstanceState()在要执行onPause()前就被调用了。而从Honeycomb开始,Activity在它们被停止了就才可以销毁,即只有Activity的onSaveInstanceState()会在onStop()之前调用。

java.lang.IllegalArgumentException:在 servlet 映射中生成无效的 <url-pattern>

【中文标题】java.lang.IllegalArgumentException:在 servlet 映射中生成无效的 <url-pattern>【英文标题】:java.lang.IllegalArgumentException: Invalid <url-pattern> generate in servlet mapping 【发布时间】:2015-02-24 22:25:36 【问题描述】:

我按照这个问题解决方案The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path 运行Tomcat 服务器时遇到了这个异常:

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/stpt-e]]
    at java.util.concurrent.FutureTask.report(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:799)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/stpt-e]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> generate in servlet mapping
    at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3279)
    at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3254)
    at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1430)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1344)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

这是怎么引起的,我该如何解决?

【问题讨论】:

【参考方案1】:

我创建了 generate.java servlet,但在该 servlet 中我将此代码 @WebServlet("/generate") 更改为 @WebServlet("generate")

【讨论】:

以上是关于Android-onSaveInstanceState方法啥时候被调用的主要内容,如果未能解决你的问题,请参考以下文章