简体   繁体   English

在Java servlet内找不到javax.ws

[英]javax.ws is not found inside a java servlet

This is my imports that can work 这是我的进口商品

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;

And this is my servlet signature: 这是我的servlet签名:

public class Multipart1 extends HttpServlet {

I am using tomcat 8. 我正在使用tomcat 8。

I want to use the MediaType enum (maybe it is a class i don't remember), and it is in the javax.ws.rs.core but the problem is that when i do import, the only thing that starts with w under javax is websocket , I couldn't find ws 我想使用MediaType枚举(也许是我不记得的类),并且它在javax.ws.rs.core但是问题是当我导入时,唯一以w开头的东西是javaxwebsocket ,我找不到ws

What am i missing please? 我想念什么?

It seems i have to include some maven dependencies, but I thought that it is a javax so it should come all together in the jdk, right? 看来我必须包括一些Maven依赖项,但是我认为这是一个Javax,因此应该将其全部放到jdk中,对吗?

It's not in the JDK, you have to import the dependency : 它不在JDK中,您必须导入依赖项:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM