[2022-04-24 04:19:03,576] Artifact week9_emp:war exploded: Error during artifact deployment. See ser

主要报错信息:

	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 <url-pattern> [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<String, String[]> 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里面的内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小海海不怕困难

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值