类"< CLASS_NAME>" nether有一个main方法,也没有在web.xml文件中指定的servlet [英] Class "<CLASS_NAME>" nether has a main method nor its servlet specified in file web.xml

查看:122
本文介绍了类"< CLASS_NAME>" nether有一个main方法,也没有在web.xml文件中指定的servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NetBeans 7.1并在其中创建了一个servlet。现在,当我运行它时,它正在给我

I am using NetBeans 7.1 and made a servlet in it. Now when I am running it, it is giving me


Class''既没有main方法也没有web.xml中指定的servlet

Class ' ' neither has a main method nor its a servlet specified in web.xml

在此之后,它又向我显示了一个错误:

After this, it is showing me one more error:


class''没有主方​​法

class ' ' does not have a main method"

我无法弄清问题是什么。我已经卸载并安装了两次NetBean但没有帮助.servlet只是一个没有逻辑的普通servlet。

I can't figure out what the problem is. I have uninstalled and installed the NetBean twice but no help. The servlet is just an ordinary servlet with no logic in it.

推荐答案

经过长时间的搜索,我得到了我认为的答案。只需添加:

After a long search I got what I feel is the answer. Just add:

@WebServlet (name="name of servlet",urlPatterns={"/url patter of servlet"})

在你的班级之上。这对我有用。

above your class. This worked for me.

这篇关于类"< CLASS_NAME>" nether有一个main方法,也没有在web.xml文件中指定的servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆