struts2+websocket报错:failed: Error during WebSocket handshake: Unexpected response code:404
最近把websocket集成进项目里面来,打开网页总是会遇到这样的错误。
网上说的原因有3种,但是都不适合我,但是也记录下。
1.struts2截拦掉了ws的请求。这种援用可以尝试把web.xml清空,如果可以连接,则是这个问题。此时在struts.xml的配置文件中添加:
<constant name="struts.action.excludePattern" value="ws://*"></constant>
对ws的请求不截拦。
2.jar包的冲突,项目里的jar包跟tomcat中的jar包冲突。
3.把java project 转化为 web project,调整包加载顺序。
然后就是自己的解决方法,ws请求的url规则是这样的:地址+端口+endpoint路径。如果在java文件中定义了端点:
@ServerEndpoint(value="/echoendpoint")
并且在本地8080端口运行,则url为 http://127.0.0.1:8080/echoendpoint
java7的websocket只需要配置endpoint,页面的JS就可以连接上,无需servlet或其他配置,只需注意下url。
struts2+websocket报错:failed: Error during WebSocket handshake: Unexpected response code:404的更多相关文章
- WebSocket connection to,Error during WebSocket handshake: Unexpected response code: 404
使用标准的JSR 356注解时,需要使用tomcat 8.x版本,如果使用tomcat 7.x的版本,则需要继承WebSocketServlet,否则会报WebSocket connection to ...
- WebSocket handshake: Unexpected response code: 404
在执行 http://www.cnblogs.com/best/p/5695570.html 提供的 websocket时候, 报错了 “WebSocket handshake: Unexpe ...
- 微信小程序WebSocket报错:Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received
Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was ...
- easyswoole报错:failed: Error during WebSocket handshake: Unexpected response code: 200
WebSocket connection to 'ws://www.xxxx.com/xxx/xx' failed: Error during WebSocket handshake: Unexpec ...
- nginx反向代理 报错:Error during WebSocket handshake: Unexpected response code: 403
遇到nginx报错:websocket wss failed: Error during WebSocket handshake: Unexpected response code: 403 serv ...
- Vue脚手架创建项目出现 (Failed to download repo vuejs-templates/webpack: Response code 404)
搭建好(脚手架2.X版本)环境像往常一样使用vue init webpack xxxx 创建项目可以是没多久就开始报错了 报错结果就是:vue-cli · Failed to download rep ...
- vue-cli 安装失败Failed to download repo vuejs-templates/vuedemo: Response code 404 (Not Found)
还原问题现场: 第一次使用vue init webpack projectName的时候,由于操作失误,执行了两次npm install -g vue-cli,然后再使用vue init webpac ...
- hive 报错FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient FAILED: Execu
使用hive一段时间以后,今天在使用的时候突然报错,如下: hive> show databases;FAILED: Error in metadata: java.lang.RuntimeEx ...
- vue-cli 安装失败Failed to download repo vuejs-templates/webapck-simple: Response code 404 (Not Found)
新学习vue的萌新们经常会遇到各种各样的坑.例如上面这个报错.这个一般是命令行面板写错单词导致. 正确:vue init webpack-simple .(注意"."点,指当前目录 ...
随机推荐
- mac php apache mysql 集成环境 的软件
http://xclient.info/s/mamp-pro.html?t=4e60e3c234937f46b33e6b15eeafeb5ee326afa4 MAMP Pro 5.1 集成web服务器 ...
- CentOS下长时间ping网络加时间戳并记录到文本
Linux下长时间ping网络加时间戳并记录到文本 由于一些原因,比如需要检查网络之间是否存在掉包等问题,会长时间去ping一个地址,由于会输出大量的信息而且最好要有时间戳,因此我们可以使用简单的 ...
- alibaba fastjson的使用总结和心得
最初接触alibaba fastjson是由于其性能上的优势,对比原来采用codehause.jackson的解析,在hadoop平台上的手动转换对象有着将近1/3的性能提升,但随着开发应用越来越 ...
- DP系列——树形DP(Codeforces543D-Road Improvement)
一.题目链接 http://codeforces.com/problemset/problem/543/D 二.题意 给一棵树,一开始所有路都是坏的.询问,以每个节点$i$为树根,要求从树根节点到其他 ...
- OpenMP Hello World
▶ OpenMP 环境配置,第一个程序 ▶ OpenMP 在Visual Studio 2015 中的配置 ● VS项目属性右键,属性,C/C++,语言,OpenMP支持,选择是(/openmp). ...
- 我的第一个C程序
// // main.c // one // // Created by Shuang Gai on 2019/1/19. // Copyright © 2019 Shuang Gai. All ri ...
- Guide to installing 3rd party JARs
Although rarely, but sometimes you will have 3rd party JARs that you need to put in your local repos ...
- Jboss:The LogManager was not properly installed (you must set the "java.util.logging.manager" system prop
可能是jboss的服务器版本选择不对 ,比如我本地的Jboss服务器版本是 jboss-as-web-7.0.2.Final,选择的服务器版本是JBOOS V7.1 Runtime ,就会报上面 ...
- 数据库框架的log4j日志配置
Hibernate log4j.logger.org.hibernate.tool.hbm2ddl=debuglog4j.logger.org.hibernate.engine.transaction ...
- METAL渲染是什么?
METAL渲染是什么? Metal渲染是由苹果公司为iOS8以及更新版本开发的全新的底层渲染API.它侧重于减少GPU驱动的工作量,从而当Metal调用时,CPU的消耗将降至最低.这样一来,游戏就可以 ...