在Windows和Linux中设计友好的JSP / Servlet Web开发(Ubuntu等)(Designer friendly JSP/Servlet web development in bo

编程入门 行业动态 更新时间:2024-10-26 00:32:12
在Windows和Linux中设计友好的JSP / Servlet Web开发(Ubuntu等)(Designer friendly JSP/Servlet web development in both Windows and Linux (Ubuntu, et. al.))

我是我的大学JSP项目的前端开发人员,到目前为止,我使用Sublime Text 2编写标记和CSS / Less,并直接从Apache Tomcat运行项目,手动配置我的项目目录放入webapps文件夹,但后来,该项目需要使用Servlets(显然),并且我意识到IDE的需求,而开发部分的同事现在坚持使用IDE。

我们已将整个项目移植到NetBeans 7.1.1,到目前为止,项目工作正常,NetBeans负责创建/管理Servlet及其web.xml配置的所有麻烦,但我主要处理标记和Less,这是真正乏味的在这里。 以下是我面临的问题:

更少的文件根本不是语法高亮的。 (尽管我将这种添加语法高亮的方式称为无文件)。

每次我对标记或CSS进行更改时,都需要按F5并等待,直到在浏览器中启动新选项卡以反映更改。 (浏览器中的刷新页面不起作用,因为它以前使用我以前的JSP开发方式工作)。 如果我看到后没有关闭标签,则可以想象10个标签可以进行10次更改。

我已经使用jQuery很多,它让我非常烦恼,在我的.js文件中看到警告(我知道NetBeans可能指向正确的问题,但我不希望它与代码“过度灵活” )。

一位网页设计师会知道“保存 - 更改为浏览器中的CSS和刷新页面”的频率。 而IDE只是减慢了整个过程。

我知道使用IDE的明显优势,但是有没有解决上述问题的方法?

另外,我尝试将我的项目移植到Eclipse(并且它只是在缩小的jQuery文件中变得疯狂),然后才转向NetBeans,但它拒绝在我的.js , .css和.less中使用相对路径<script>和<alt>即使所有的文件和文件夹都存在于Web内容目录中。 尽管事实上我可以访问手动访问URL的这些文件,但我得到的404错误是我的脚本和样式表。 如下:

<link rel="stylesheet/less" href="less/styles.less" media="all" /> <!-- Above line doesn't include the file and I get 404 error -->

Visiting to localhost:8080/MyProject/less/styles.less shows me its content in the browser.

另外,我试图在不使用IDE的情况下使用Servlet(我的Java代码很简单,以至于我不觉得有任何类似于IntelliSense的编辑需要)并且引用了这个链接,并且如果我以与但我不明白为什么我需要在编译时在classpath中指定apache-tomcat\lib servlet-api.jar ,尽管事实上我有Apache的lib文件夹的路径已经添加到Windows中的CLASSPATH变量。

我知道在这个单一问题中有太多的问题,它可能会被SO主持人“主持”,但是我的所有问题都暗示了必须开发JSP / Servlet和在不使用IDE的情况下设计页面的单一问题,以及只是相当有用的文本编辑AKA崇高文本。

请给我一个坚定的解决方案。

I'm a front-end developer for my college JSP project and so far I was using Sublime Text 2 for writing markup and my CSS/Less and ran the project directly from Apache Tomcat configured manually where I placed my project directory in webapps folder, but later, the project required to use Servlets (obviously) and I realized the need of IDE, while my colleagues at the development part are now insisting to use IDE.

We have ported the entire project to NetBeans 7.1.1 and so far, project works fine and NetBeans takes care of all the hassle of creating/managing Servlets and its web.xml configurations, but I mainly deal with the markup and Less, which is real tedious here. Following are the issues I face:

Less file is not syntax-highlighted at all. (although I referred this way of adding Syntax highlight to .less files).

Every time I make a change to markup or CSS, I need to hit F5 and wait till a new tab launches in browser to reflect the changes. (Refreshing page in the browser doesn't work as it used to work in my older way of JSP development). Imagine 10 tabs for 10 changes if I don't close the tab after I see.

I've used jQuery a lot, and it really annoys me to see warnings in my .js files (I know NetBeans might be pointing to correct issues, but I simply don't want it to be "over-smart" with my code).

A Web designer would know how frequent it is to "save-changes-to-css-and-refresh-page-in-browser". And the IDE just slows down this whole process.

I know the obvious advantages of using IDE, but is there any fix for above issues?

Also, I tried porting my project to Eclipse (and it just went crazy on minified jQuery files), before turning to NetBeans, but it just refused to use relative paths for my .js,.css and .less in <script> and <alt> tags, even though all the files and folders existed within Web-Content directory. And all I got was 404 errors for my scripts and stylesheets, in spite the fact that I could access those files my manually visiting to URL. As follows:

<link rel="stylesheet/less" href="less/styles.less" media="all" /> <!-- Above line doesn't include the file and I get 404 error -->

but

Visiting to localhost:8080/MyProject/less/styles.less shows me its content in the browser.

Also, I tried to work with Servlets without using IDE (my Java code is simple such that I don't feel any need of IntelliSense-like editing) and refered this link, and ya it works if I do it in the same way as explained, but I don't get why I need to specify servlet-api.jar of apache-tomcat\lib in classpath at the time of compilation inspite the fact that I have path to Apache's lib folder already added to CLASSPATH variable in Windows.

I know there are too many questions within this single question that it is likely to be "moderated-out" by SO moderators but my all questions hint to a single problem of having to develop JSP/Servlets and designing the pages without using IDE, and just fairly capable text-editor AKA Sublime Text.

Please suggest me a firm solution.

最满意答案

我相信你最终将从使用IDE开始Java Web应用程序开发(例如NetBeans)最终获益,尽管更换新工具绝非易事。

NetBeans是HTML,JavaScript和CSS的良好文本编辑器。 它提供了语法高亮,格式化,代码完成,内联文档,CSS颜色/效果预览和验证。

NetBeans可以轻松配置为部署到运行在您计算机上的Tomcat实例。 此后,NetBeans中HTML,JSP和CSS的任何编辑通常会自动反映到正在运行的应用程序中(仅需要刷新F5页)。

有些情况下,CSS更改不会自动反映到正在运行的应用程序中。

如果您在构建过程中缩小了CSS,那么浏览器正在加载CSS的缩小版本(例如,使用YUI压缩器 ,最好在完成CSS开发之后再使用它)。 如果你正在使用某种CSS文件缓存过滤器。 例如,您明确地为CSS文件设置了过期标题,从而导致浏览器将CSS缓存一段时间。 您可以在外部编辑器中编辑您的JS / CSS,NetBeans在检测由外部编辑器所做的更改方面做得非常好,但有时它不会检测到这些更改,除非NetBeans编辑器内部进行了最新更改。

由于您没有遇到即时更新,因此我认为这是您使用LESS的问题,而不是NetBeans本身。

我没有使用LESS,而是在快速提示中找到了一个解决方案:LESS.js处于开发和监视模式 ,显然如果您在HTML5浏览器中运行less.js,本地存储将用于缓存生成的CSS。 这是正常使用的一个很好的功能,但不是您在开发CSS时想要的功能,因为您不会立即看到CSS更改的结果。 解决方案是使用LESS的手表和开发模式。 Watch模式可以让CSS自动刷新(无需点击F5),开发模式可以防止CSS被缓存。

您可以在加载少量样式表和less.js脚本后添加以下JavaScript来启用监视模式。

<script type="text/javascript"> less.env = "development"; less.watch(); </script>

如果你认为NetBeans对你的JavaScript太聪明了,你应该看看JSLint会用它做什么! 它可能是一个破坏你的代码运行过多质量工具的小灵魂,说我总是使用Firefox HTML验证器扩展 (我活着看到绿色的滴答声!)。 NetBeans警告可能看起来有点可怕,但它只是试图让你符合标准,以帮助你避免进一步的问题。

当我看到您的短语“ 将整个项目移植到NetBeans 7.1.1 ”时,我有点担心,我个人建议您的项目应该使用IDE不可知的构建工具(如Ant或Maven)构建。 NetBeans对这两种工具都有非常好的支持,我自己也是一个很大的Maven粉丝。 使用这些构建工具意味着您可以避免使用IDE并使用命令行构建应用程序的实例。

顺便说一下,我希望你使用的是像Git或Subversion这样的版本控制系统来共享项目文件的更改,IDE也可以很容易地使用版本控制系统。

关于你的其他问题。 Apache和Apache Tomcat是两种不同类型的服务器软件。 通常Apache服务器安装在Tomcat服务器的前面。 编译Servlet时,您的Java编译器需要访问servlet-api.jar的副本。 Tomcat的lib目录包含Java库文件(例如servlet-api.jar),Apache的lib目录将包含由Apache 本机可执行文件使用的编译C库,而不是Java库文件(这些是用于不同目的的不同类型的库)。

I believe you will ultimately gain from using an IDE for Java web application development (e.g. NetBeans) in the long run although changing to new tools is never easy.

NetBeans is a good text editor for HTML, JavaScript and CSS. It provides syntax highlighting, formating, code completion, inline documentation, previews for CSS colors/effects and validation.

NetBeans can easily be configured to deploy to a Tomcat instance running on your machine. After which time any editing of HTML, JSPs and CSS within NetBeans is usually automatically reflected in your running application (requiring only an F5 page refresh).

There are situations when CSS changes will not be automatically reflected in the running application.

if you are minifying the CSS during your build process, so your browser is loading a minified version of your CSS (e.g. using the YUI compressor, best to leave using this until after you have finished the CSS development). if you are using some kind of CSS file caching filters. e.g. you are explicitly setting an expiry header for the CSS file and thus causing the browser to cache the CSS for a period of time. You can edit your JS/CSS in an external editor, NetBeans does a pretty good job of detecting changes made by external editors but sometimes it doesn't detect these unless the most recent change has been made inside the NetBeans editor itself.

Since you are not experiencing instant update I would assume this is an issue with your usage of LESS rather than due to NetBeans itself.

I've not used LESS myself but found a solution at Quick tip: LESS.js in development and watch mode, apparently if you are running less.js in a HTML5 browser local storage will be used to cache the generated CSS. This is a good feature for normal usage but not something you want when you are developing your CSS as you will not immediately see the results of your CSS changes. The solution is to use LESS's watch and development modes. Watch mode enables your CSS to be refreshed automatically (no need to hit F5) and development mode will prevent the CSS from being cached.

You can enable watch mode by adding the following JavaScript after your less stylesheets and less.js script is loaded.

<script type="text/javascript"> less.env = "development"; less.watch(); </script>

If you think NetBeans is being too smart about your JavaScript you should see what JSLint would make of it! It can be a little soul destroying to run too many quality tools against your code, that said I always use the Firefox HTML Validator extension (I live to see the green ticks!). The NetBeans warnings may look a little scary but it is only trying to keep you standards compliant to help you avoid problems further down the line.

I was a little concerned when I saw your phrase "ported the entire project to NetBeans 7.1.1", personally I would advise that your project should be built using a build tool that was IDE agnostic (such as Ant or Maven). NetBeans has very good support for both of these tools, I'm a big Maven fan myself. Using these build tools would mean you could avoid using an IDE and build your instance of the application using the command line instead.

Incidentally, I would hope you are using a version control system such as Git or Subversion to share project file changes, IDEs also make it easy to work with version control systems.

In relation to your other question. Apache and Apache Tomcat are two different types of server software. Often Apache server is installed in front of a Tomcat server. When compiling a Servlet your Java compiler will need access to a copy of servlet-api.jar. Tomcat's lib directory contains Java library files (e.g. servlet-api.jar), the Apache's lib directory will contain compiled C libraries used by the Apache native executables rather than Java library files (these are different types of library for different purposes).

更多推荐

本文发布于:2023-07-28 01:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1298311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:友好   Servlet   Web   JSP   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!