[2022-04-24 04:19:03,576] Artifact week9

[2022-04-24 04:19:03,576] Artifact week9,第1张

主要报错信息:

	Caused by: java.lang.IllegalStateException: Error starting child
		at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
		at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
		at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
		at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1783)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:293)
		... 35 more
	Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/week9_emp]]
		at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
		at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
		... 43 more
	Caused by: java.lang.IllegalArgumentException: Invalid  [Login] in servlet mapping
		at org.apache.catalina.core.StandardContext.addServletMappingDecoded(StandardContext.java:3233)
		at org.apache.catalina.Context.addServletMappingDecoded(Context.java:905)
		at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1562)
		at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1329)
		at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:986)
		at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:303)
		at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
		at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135)
		at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
		... 44 more
[2022-04-24 04:19:03,576] Artifact week9_emp:war exploded: Error during artifact deployment. See server log for details.
24-Apr-2022 16:19:11.497 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Program\JavaEnvironment\tomcat-9.0.62\webapps\manager]
24-Apr-2022 16:19:11.675 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Program\JavaEnvironment\tomcat-9.0.62\webapps\manager] has finished in [177] ms

错误代码:

@WebServlet("Login")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Map parameterMap = req.getParameterMap();
        Emp emp = new Emp();

        try {
            BeanUtils.populate(emp,parameterMap);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        EmpServiceImpl empService = new EmpServiceImpl();

        Emp emp1 = empService.queryEmp(emp);

        if(emp1!=null){

            resp.getWriter().write("login success");

        }else {

            resp.getWriter().write("login fail");

        }

    }


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);



    }


}

错误原因分析:

tomcat报错时我们需要关注的是caused by 的内容而不是,白色字的部分,因为那里不提供报错信息,白色字体的意思是在部署的时候出现了错误,更多的错误信息请看日志。二日志就在白色字体的上方,你看到打一个 caused by,它说我们的URL-pattern配置错误,原来是我在写@WebServlet("Login")时忘写了斜杠,添加后程序就正常运行了。大家以后要多关注caused by里面的内容。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/735903.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存