weixin_35053936
weixin_35053936
2016-12-09 15:58
采纳率: 40%
浏览 1.5k
已采纳

java web 里面在xml里面配置servlet时出现了如下错误

刚开始是这样的
图片说明
后来又刷新了一遍
图片说明

我已经快疯了,网上说是类名不对,可是我的是对的啊
package MyServelet;

import java.io.IOException;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class MyFirstServelet implements Servlet
{

@Override
public void destroy() {
    // TODO Auto-generated method stub
    System.out.println("destroy");
}

@Override
public ServletConfig getServletConfig() {
    // TODO Auto-generated method stub
    System.out.println("getServletConfig");
    return null;
}

@Override
public String getServletInfo() {
    // TODO Auto-generated method stub
    System.out.println("getServletInfo");
    return null;
}

@Override
public void init(ServletConfig arg0) throws ServletException {
    // TODO Auto-generated method stub
    System.out.println("init");
}

@Override
public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException {
    // TODO Auto-generated method stub
    System.out.println("service");
}

public MyFirstServelet()
{
System.out.println("我成功了。。。。。");
}
}

<?xml version="1.0" encoding="UTF-8"?>


hello

<servlet-class>MyServelet.MyFirstServelet</servlet-class>



hello
/happy

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • wojiushiwo945you
    毕小宝 2016-12-09 23:38
    已采纳

    项目clean下,可能是编译类文件没有发布过去。

    点赞 评论
  • devmiao
    devmiao 2016-12-09 15:56
    点赞 评论
  • weixin_35053936
    weixin_35053936 2016-12-09 16:09

    <?xml version="1.0" encoding="UTF-8"?>


    hello
    MyServelet.MyFirstServelet


    hello
    /happy

    点赞 评论
  • u012401711
    JAVA_DIRECTION 2016-12-09 22:50

    xml中配置的时候
    类名写全包名+类名

    映射的url把工程名加上/SP01/happy

    点赞 评论

相关推荐