Eclipse(Helios)偶尔会将有效的JSP内容标记为有错误.当我使用<c:if>标签时,它似乎经常会中断.例如,在仅包含此内容的JSP中:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<c:if test="${1 == 1}">
something
</c:if>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
编译后,"问题"选项卡中显示以下错误:
代码运行正常.对JSP的验证是否有问题,我是否遗漏了一些明显的问题,或者这表明某些内容未正确设置.
如果我在Web服务器(Tomcat)中有一个文件并创建一个标签,我可以观看视频,暂停它,浏览它,并在完成后重新启动它.
但是如果我创建一个在请求时发送视频文件的REST接口,并将其URL添加到标签,我只能播放和暂停.没有倒带,没有快进,没有导航,没有.
那么,有没有办法解决这个问题?我在某处遗漏了什么吗?
视频文件与REST接口位于同一服务器中,REST接口仅检查会话并在找到应发送的视频后发送视频.
这些是我到目前为止尝试过的方法.它们都有效,但没有一个允许导航.
/*
* This will actually load the whole video file in a byte array in memory,
* so it's not recommended.
*/
@RequestMapping(value = "/{id}/preview", method = RequestMethod.GET)
@ResponseBody public ResponseEntity<byte[]> getPreview1(@PathVariable("id") String id, HttpServletResponse response) {
ResponseEntity<byte[]> result = null;
try {
String path = repositoryService.findVideoLocationById(id);
Path path = Paths.get(pathString);
byte[] image = Files.readAllBytes(path);
response.setStatus(HttpStatus.OK.value());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentLength(image.length);
result = new ResponseEntity<byte[]>(image, headers, HttpStatus.OK);
} catch …Run Code Online (Sandbox Code Playgroud) 有点懒,我很高兴发现我可以通过New - > Servlet来创建一个新的servlet源代码,而不是去New - > Class然后将类编辑成一个servlet.
但是,我发现每次在Eclipse中创建一个新的servlet时,Eclipse都会修改我的web.xml.
具体来说,它将top元素修改为:
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
id="WebApp_ID" version="2.4">
Run Code Online (Sandbox Code Playgroud)
(我的线路爆炸.)
这似乎并不一定是坏事,但它通过在其名称前面加上"javaee:"来修改各种子元素,以指示这些元素属于该命名空间.
例如,它会改变
<display-name>ShowLifecycles</display-name>
Run Code Online (Sandbox Code Playgroud)
至
<javaee:display-name>ShowLifecycles</javaee:display-name>
Run Code Online (Sandbox Code Playgroud)
之后,eclipse会抱怨它修改的所有元素,给我一些符号:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'javaee:display-name'. One of '{"http://
java.sun.com/xml/ns/j2ee":description, "http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/
j2ee":icon, "http://java.sun.com/xml/ns/j2ee":distributable, "http://java.sun.com/xml/ns/j2ee":context-param, "http://
java.sun.com/xml/ns/j2ee":filter, "http://java.sun.com/xml/ns/j2ee":filter-mapping, "http://java.sun.com/xml/ns/
j2ee":listener, "http://java.sun.com/xml/ns/j2ee":servlet, "http://java.sun.com/xml/ns/j2ee":servlet-mapping, "http://
java.sun.com/xml/ns/j2ee":session-config, "http://java.sun.com/xml/ns/j2ee":mime-mapping, "http://java.sun.com/xml/ns/
j2ee":welcome-file-list, "http://java.sun.com/xml/ns/j2ee":error-page, "http://java.sun.com/xml/ns/j2ee":jsp-config, "http://
java.sun.com/xml/ns/j2ee":security-constraint, "http://java.sun.com/xml/ns/j2ee":login-config, "http://java.sun.com/xml/ns/
j2ee":security-role, "http://java.sun.com/xml/ns/j2ee":env-entry, "http://java.sun.com/xml/ns/j2ee":ejb-ref, "http://
java.sun.com/xml/ns/j2ee":ejb-local-ref, "http://java.sun.com/xml/ns/j2ee":service-ref, "http://java.sun.com/xml/ns/
j2ee":resource-ref, "http://java.sun.com/xml/ns/j2ee":resource-env-ref, "http://java.sun.com/xml/ns/j2ee":message-
destination-ref, "http://java.sun.com/xml/ns/j2ee":message-destination, "http://java.sun.com/xml/ns/j2ee":locale-
encoding-mapping-list}' is expected.
Run Code Online (Sandbox Code Playgroud)
更糟糕的是,当我使用find和replace将所有内容删除到"javaee:"中时,Eclipse仍会抱怨这些文件,即使它们不再存在.我必须将整个剩余文件复制并粘贴到自身之上,以避免这些投诉.
我确信Eclipse正在努力发挥作用,期待这个命名空间的一些愿望或需求.我怎样才能做以下两件事之一: …