servlet

IDEA导入eclipse项目servlet运行404

断了今生、忘了曾经 提交于 2019-12-03 04:52:37
接上文,在把eclipse中的web项目导入的idea时,昨天只是运行了一下能跑,今天仔细运行发现,jsp均能正常显示,但是一到servlet就404,依旧是地址问题。 首先想到是否是web.xml没有加载成功,于是前往项目中的Facets,查看web resource directories配置,结果果然是错误的,因为是导入eclipse中的项目,web.xml我们通常放在webroot或webcontent的WEB-INF下,而idea默认在web这个路径下,需要修改。修改完毕后重新run,结果还是错误。然后查看url,在8080后自动添加了项目名,上文提到过idea默认的路径不带项目名,感觉是这个问题,于是去tomcat中修改下配置,把默认的/后面加上了项目名,再次运行,果然成功。 所以,直接导入eclipse项目还是会出现很多问题的,建议把eclipse中项目的多余文件删除,只留下src和webroot2个目录,然后新建web项目放进去,问题应该会减少很多。 ps:现在注册JetBrains非常方便,2封邮件即搞定,学生时代的福利还是要好好利用的。 来源: CSDN 作者: yyyyyhu 链接: https://blog.csdn.net/huyang0304/article/details/78027257

springmvc的入门

梦想的初衷 提交于 2019-12-03 04:35:23
1. 什么是springMVC? Spring Web MVC是一种基于Java的实现了MVC设计模式的、请求驱动类型的、轻量级Web框架。 2. SpringMVC处理请求的流程 2.1 首先用户发送请求-->DispatherServlet 2.2 DispatcherServlet-->HandlerMapping 2.3 DispatcherServlet-->HandlerAdapter 2.4 HandlerAdapter-->处理器功能处理方法的调用 2.5 ModelAndView的逻辑视图名-->ViewRecolver 2.6 View-->渲染 2.7 返回控制权给DispatcherServlet,由DispatcherServlet返回呼应给用户,流程结束 3. SpringMVC核心开发步骤 3.1 DispatcherServlet在web.xml中的部署描述,从而拦截请求到springMVC 3.2 HandlerMapping的配置,从而将请求映射到处理器 3.3 HandlerAdapter的配置,从而支持多种类型的处理器 3.4 处理器(页面控制器)的配置,从而刊行功能处理 3.5 ViewResolver的配置,从而将逻辑视图名解析为具体的视图技术 4. SpringMVC的组件 4.1 前端控制器(DispatcherServlet) 4

servlet服务器

笑着哭i 提交于 2019-12-03 04:33:42
在项目中的web.xml配置servlet <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <!-- 告诉servlet这个名字 --> <servlet> <servlet-name>servelt</servlet-name> <servlet-class>com.hei.servelt</servlet-class> </servlet> <!-- 注册servelt的映射,通过访问url这个路径,访问这个servletd的名字 --> <servlet-mapping> <servlet-name>servelt</servlet-name> <url-pattern>/a</url-pattern> </servlet-mapping> <servlet> <servlet-name

Dubbo笔记

怎甘沉沦 提交于 2019-12-03 04:31:29
SOA架构(Service Oriented Ambiguity)面向服务架构 有一个或多个与数据库交互并 向外提供服务的的单元,在注册中心注册向外提供的服务 其他单元不与数据库进行交互,从注册中心获取提供的服务单元的一系列信息,并直接调用提供服务的单元. 这样的设计避免了根据业务区分模块,每个业务模块都与数据库进行交互,有一些相同的操作会在不同的模块 冗余 地存在 常用的服务: Dubbo.WebService,Dubbox,Web项目 RPC(Remote Procedure Call Protocol)远程过程调用协议 客户端通过互联网调用远程服务器,不知道远程服务器具体实现,只知道远程服务器提供了什么功能. 本次主要学习Dubbo这种rpc框架 Dubbo简介 一个分布式、高性能、透明化的RPC服务框架 提供服务自动注册、自动发现等高效服务治理方案. Dubbo 架构图 Provider :提供者,服务发布方. Consumer:消费者, 调用服务方 Container:Dubbo容器.依赖于Spring容器. Registry: 注册中心.当Container启动时把所有可以提供的服务列表上Registry中进行注册.作用:告诉Consumer提供了什么服务和服务方在哪里. Monitor:监听器 虚线都是异步访问,实线都是同步访问 蓝色虚线:在启动时完成的功能 绿色虚线

Spring Boot 自定义注册 Servlet、Filter、Listener

半世苍凉 提交于 2019-12-03 04:14:13
前言 在 Spring Boot 中已经移除了 web.xml 文件,如果需要注册添加 Servlet、Filter、Listener 为 Spring Bean,在 Spring Boot 中有两种方式: 使用 Servlet 3.0 API 的注解 @WebServlet、@WebFilter、@Listener 用来配置。 Spring Boot JavaConfig 注解配置 Bean 的方式来进行配置。 注册之前 在使用 Servlet 时,需要在 Spring Boot 入口类添加 @ServletComponentScan 注解,告诉 Spring Boot 去扫描使用下面注册的 Servlet、Filter、Listener。 @SpringBootApplication @ServletComponentScan public class SpringBootServletApplication { public static void main(String[] args) { SpringApplication.run(SpringBootServletApplication.class, args); } } 注册 Servlet 1.@WebServlet 属性 属性 类型 描述 name String 指定Servlet名称,等价于 value

Does Dropwizard Support Servlet 3 Asynchronous Servlets?

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Does Dropwizard support Servlet 3 asynchronous servlets? If not, is it on the roadmap at any time in the near future? 回答1: It uses Jetty 8, which supports Servlet 3.0. Jersey (and JAX-RS) doesn't have any support for this, but it's forthcoming in JAX-RS 2.0 (and Jersey 2.0). Dropwizard doesn't add anything special, but when Jersey 2.0 ships, the next major Dropwizard release will very likely include it. 回答2: You can use https://github.com/jetty-project/jetty-eventsource-servlet . Read wiki for how to impl Servlet and EventSource In your DW

SecurityContext doesn&#039;t work with @RolesAllowed

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm currently creating a backend server using Jersey 2.5.1 in a Tomcat 7. For the security I'm using the @RolesAllowed , @PermitAll etc. annotations, and I have created my custom ContainerRequestFilter and SecurityContext . My problem is that when my @RolesAllowed annotated resource is requested it always denies permission, even if I force my isUserInRole(role) method to return true . However, my filter method gets called. Do you have any suggestions? I'll paste some relevant code below. My ContainerRequestFilter implementation: public class

Maven Tomcat Embedded

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to run a Spring webapp using maven with the mvn tomcat:run command, but whenever I navigate to http://localhost:8080/myApp , I get the error: "The requested resource () is not available". Nothing shows up in the logs. I think my app is supposed to be deployed to "/" instead of "/myApp". Is there a way to do this? Maven output log: [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'tomcat'. [INFO] ------------------------------------------------------------------------ [INFO] Building myApp [INFO]

HTTP Status 405 - HTTP method GET is not supported by this URL [duplicate]

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: HTTP Status 405 - HTTP method GET is not supported by this URL 2 answers The code below is from a book,so it'll not be incorrect.But I don't know how to solve this below error.When delete the method doGet(),the same error! "HTTP Status 405 - HTTP method GET is not supported by this URL" import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax

Jersey java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to make a web-service with Tomcat and Eclipse using jersey library. This is my service class: package com.gontuseries.university; import javax.ws.rs.core.MediaType; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/university") public class UniversityRestWs { @GET @Produces(MediaType.TEXT_HTML) public String getHtmlUniversityInfo(){ return "<html><body>test</body></html>"; } @GET @Produces(MediaType.TEXT_PLAIN) public String getTextUniversityInfo(){ return "test"; } } And this is file web.xml