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 .(注意"."点,指当前目录 ...
随机推荐
- SQL中減少日志文件大小
SQL中減少日志文件大小 编写人:CC阿爸 2014-6-14 在日常SQL数据库的操作中,常常会出现SQL日志文件超大,大小都超过正常MDF数据库文件,作为一般用户来讲,LDF太大,只会影响服务 ...
- 编译sass,遇到报错error style.scss (Line 3: Invalid GBK character "\xE5")
今天学习sass,写了一行中文注释,结果却遇到了报错: cmd.exe /D /C call C:/Ruby23-x64/bin/scss.bat --no-cache --update style. ...
- sql 如何更改表的字段属性
alter table tablename alter column colname newDataType 比如:ALTER TABLE mytable ALTER COLUMN myco ...
- p3新式类__new__使用和实例化
嗯,new方法返回的是一个全新的对象是真正在内存中分配的内存地址 示例1·class Foo(object): # __metaclass__ = MyType def __init__(self, ...
- 读Understanding the Linux Kernel, 3rd Edition有感
14.3.2.2. Avoiding request queue congestion Each request queue has a maximum number of allowed pendi ...
- windows拖动文件到Ubuntu
只需要安装 sudo apt install lrzsz
- vuex和vuejs
前言:在最近学习 Vue.js 的时候,看到国外一篇讲述了如何使用 Vue.js 和 Vuex 来构建一个简单笔记的单页应用的文章.感觉收获挺多,自己在它的例子的基础上进行了一些优化和自定义功能,在这 ...
- leetcode290
public class Solution { public bool WordPattern(string pattern, string str) { var list = str.Split(' ...
- JPA with Hibernate implementation
https://code.google.com/p/jpa-basics-tutorial/source/checkout http://alextretyakov.blogspot.com/2013 ...
- “MSDTC 事务的导入失败: Result Code = 0x8004d00e。
今天搞数据库移植,也把分布式程序移植了一下,一直报上面的错误,差点要重装了 %>_<%,网上看了几篇文章偶然间用DPCPING工具测试了下连接,发现不行.想到host文件的配置,发现其中 ...