I've been doing PHP/MySQL web development for a while and I'm fairly competent in it. Lately however, I've learnt Java and fallen in love with it, and I'd really like to do more Java work now.
我已经做了一段时间的PHP / MySQL Web开发,我很有能力。然而,最近我学会了Java并爱上了它,我现在真的想做更多的Java工作。
I've gotten my first opportunity with a client who needs a web 2.0ish web app built, and he has agreed to let me use anything I want to, including Java. However, I haven't done any web dev. in Java before, I've only went through the official Java tutorial, learnt a bit about applets and build a 2D pacman game, and have done some simple work in Google Web Toolkit.
我有一个客户需要构建一个web 2.0ish Web应用程序的第一次机会,他同意让我使用我想要的任何东西,包括Java。但是,我还没有做任何网络开发。在Java之前,我只是通过官方的Java教程,学习了一些applet并构建了一个2D pacman游戏,并在Google Web Toolkit中做了一些简单的工作。
I need to get started with this project in the next 2-3 days max, so I don't have much time to read long books about the topic. This is what I've learnt so far:
我需要在接下来的2-3天内开始使用这个项目,所以我没有太多时间阅读有关该主题的长篇书。这是我到目前为止所学到的:
- Setup a Tomcat on my dev machine to work with Eclipse
- Learnt the basics of servlets, the
doPost()
,doGet()
andinit()
methods, etc - Built a mini MVC app which displays a HTML page, lets you pick something from a dropdown and when you hit submit, it retrieves your submitted value through
request.getParameter()
in thedoPost()
function, and then forwards on to a JSP page which shows which value you picked.
在我的开发机器上设置Tomcat以使用Eclipse
学习了servlet的基础知识,doPost(),doGet()和init()方法等
构建了一个显示HTML页面的迷你MVC应用程序,允许您从下拉列表中选择一些内容,当您点击提交时,它会通过doPost()函数中的request.getParameter()检索您提交的值,然后转发到JSP页面它显示了您选择的值。
I think these are the next few things I'd need to learn:
我认为这些是我需要学习的下几个方面:
- How to access/use databases
- Sessions and Cookies
- Possibly more about the syntax of JSP pages.
如何访问/使用数据库
会话和Cookie
可能更多关于JSP页面的语法。
There seem to be hundreds of topics about Java web dev which I don't know anything about., but I don't have time to learn everything. I need someone to point out any other crucial things I'd need to learn, in order to build this web app (with perhaps 20 screens) using Java and Google Web Toolkit.
似乎有数百个关于Java web dev的主题,我对此一无所知。但我没有时间学习所有内容。我需要有人指出我需要学习的任何其他重要的事情,以便使用Java和Google Web Toolkit构建这个Web应用程序(可能有20个屏幕)。
Also, I'm coming from a CodeIgniter background which is an MVC framework in PHP that makes things like form validation, sessions management (it uses database sessions), pagination, and common tasks like these very easy. If there is a similar, lightweight framework in Java that can take care of things like this, please mention it as well.
此外,我来自CodeIgniter背景,这是一个PHP中的MVC框架,它使形式验证,会话管理(它使用数据库会话),分页和这些常见任务非常容易。如果Java中有类似的轻量级框架可以处理这样的事情,请同时提及它。
Thanks.
11 个解决方案
#1
There are so many different Java Enterprise technologies it's pretty hard to know where to start. As previously mentioned, the head first JSP & Servlets book is excellent. I currently work on an Enterprise app that was made years ago with just Servlets. We have migrated over to JSP's as time has gone on but we are not using any of the newer frameworks. So it is for sure a valid way to do it, although dated.
有许多不同的Java Enterprise技术,很难知道从哪里开始。正如前面提到的,头部第一本JSP和Servlets书籍非常出色。我目前正在使用几年前只使用Servlet创建的企业应用程序。随着时间的推移,我们已经迁移到JSP,但我们没有使用任何新的框架。所以它确实是一种有效的方法,尽管已经过时了。
The thing about java, is that most enterprise development is a conjunction of a bunch of different technologies. For example, you could create an app using JSP's for the views with a Servlet back-end, using Hibernate for you DB connections, JDOM for your XML, JUnit for your testing framework, Log4j or AspectJ for your logging framework, Lucene for search, JBoss for deployment (and deployment can be pretty non-trivial) etc. etc. etc. You aren't going to go out and learn all of those technologies in the next 3 days.
关于java的事情是,大多数企业开发是一堆不同技术的结合。例如,您可以使用JSP为使用Servlet后端的视图创建应用程序,使用Hibernate进行数据库连接,使用JDOM进行XML连接,使用JUnit进行测试框架,使用Log4j或AspectJ进行日志记录框架,使用Lucene进行搜索,用于部署的JBoss(以及部署可能非常重要)等等。您不会在接下来的3天内出去学习所有这些技术。
What I would suggest is (as previously mentioned) to pick a framework, and there are many to choose from such as Tapestry, JSF, Wicket, Struts, etc. that will abstract away a lot of the underlying technologies. Any java technology you pick will have a good community behind it willing to help.
我建议(如前所述)选择一个框架,有很多可供选择,如Tapestry,JSF,Wicket,Struts等,它们将抽象出很多底层技术。您选择的任何Java技术都将拥有一个愿意提供帮助的良好社区。
Another thing to consider, since you seem to be in a hurry to get things working, is that (in my opinion at least) Java is not a FAST language to build things in. It is very verbose and unless you grasp the nuances of good Java web design it is very easy to shoot yourself in the foot. Perhaps you should look at some of the other technologies that are available on the JVM (so that you have all the Java libs available) such as Groovy.
另一件需要考虑的事情是,因为你似乎急于让事情发生,所以(至少在我看来)Java并不是一种快速构建内容的语言。它非常冗长,除非你掌握好的细微差别Java网页设计很容易在脚下拍摄自己。也许您应该查看JVM上可用的其他一些技术(以便您拥有所有可用的Java库),例如Groovy。
Groovy allows you the ability to program with Java syntax if you choose, or a dynamic Ruby-like syntax. Additionally, Grails is pretty much a Rails clone for Groovy and will let you write a web app in no time at all.
如果您愿意,Groovy允许您使用Java语法编程,或者使用类似动态的Ruby语法。另外,Grails几乎是Groovy的Rails克隆版,可以让你立刻编写一个Web应用程序。
Whatever you choose to do, good luck and welcome to the wonderful world of Java Web Apps.
无论您选择做什么,祝您好运,欢迎来到Java Web Apps的精彩世界。
#2
You should skip basic servlets and use a web framework, from Struts + Tiles (simple to get to grips with - a few hours at most) to Spring, etc. In your case I would also use Hibernate for database abstraction - you don't get up to speed with JDBC in such a short time.
你应该跳过基本的servlet并使用一个Web框架,从Struts + Tiles(简单到掌握 - 最多几个小时)到Spring等等。在你的情况下我也会使用Hibernate进行数据库抽象 - 你没有在如此短的时间内熟悉JDBC。
#3
As a start, I would recommend you pick up Head First Servlets & JSP. It will give you a nice overview of Java web development. From their you would be better able to pick a web framework to use.
首先,我建议您选择Head First Servlets和JSP。它将为您提供Java Web开发的精彩概述。从他们那里你可以更好地选择一个使用的Web框架。
#4
I'd recommend Matt Raible's app fuse .
我推荐Matt Raible的应用程序保险丝。
It will give you a crash course in hooking your app up to a database, using a mvc framework, as well as some of the java build tools. This App fuse demo will show how quickly he gets things rolling.
它将为您提供一个速成课程,将您的应用程序连接到数据库,使用mvc框架以及一些Java构建工具。这个App保险丝演示将展示他如何快速地推动事物的发展。
#5
For basic simple java based web-app follow below things
对于基本的简单的基于Java的web-app,请遵循以下内容
- Install IDE (eg. eclipse,netbeans)
- Install web/application server (eg. Tomcat/Jboss)
- Configure server in IDE
- Create new dynamic web project with JSP/Servlet
- learn/develop and run sample applications which includes advance technology like Spring,Struts,Hibernate,EJB etc.
安装IDE(例如eclipse,netbeans)
安装Web /应用程序服务器(例如Tomcat / Jboss)
在IDE中配置服务器
使用JSP / Servlet创建新的动态Web项目
学习/开发和运行示例应用程序,其中包括Spring,Struts,Hibernate,EJB等先进技术。
I believe design is more important than technology, so keep learning design patterns. all major frameworks are based on different design pattern.
我相信设计比技术更重要,所以要不断学习设计模式。所有主要框架都基于不同的设计模式。
#6
I would suggest that you try JSP first. JSP is simpler since you don't have to deal with the underlying server technology, not for simple applications atleast. It will get you up to speed. Later, as you gain experience, you can use servlets directly.
我建议你先尝试JSP。 JSP更简单,因为您不必处理底层服务器技术,而不是简单的应用程序。它会让你加快速度。之后,随着经验的积累,您可以直接使用servlet。
It will also fit well with your PHP intuitions.
它也适合您的PHP直觉。
#7
It's true that starting with Java Web development is not as easy as PHP, especially with CodeIgniter, a framework that I've fallen in love with.
确实,从Java Web开发开始并不像PHP那么容易,尤其是CodeIgniter,这是我爱上的框架。
I'd recommend Grails, but first pick up a book on the subject. I've found that in order to get productive quickly you'll need a proper reference. Personally I used The definitive guide to Grails.
我推荐Grails,但首先拿起一本关于这个主题的书。我发现为了快速提高效率,你需要一个适当的参考。就个人而言,我使用了Grails的权威指南。
#8
I would recommend grabbing a copy of the Servlet 2.5 Specification for reference purposes. It's a fairly nice read, and not too dry for a specification.
我建议抓取Servlet 2.5规范的副本以供参考。这是一个相当不错的阅读,并且对于规范来说并不太干。
It explains about Sessions, Filters, Listeners, threading model, etc...
它解释了会话,过滤器,监听器,线程模型等...
Also, take a look at the JSP Model 2 architecture (better link) which explains the best use of servlets and JSPs.
另外,请看一下JSP Model 2架构(更好的链接),它解释了servlet和JSP的最佳用途。
I wouldn't recommend looking at Struts or Spring if you only have a few days to get up to speed from scratch. Once you have gained familiarity with servlets and JSPs, then you could look at Spring MVC for an approach that supports easier unit testing for controllers.
如果你只有几天时间从头开始加速,我不建议你看看Struts或Spring。一旦熟悉了servlet和JSP,就可以看一下Spring MVC,它支持更简单的控制器单元测试。
#9
You should better learn basic servlet and JSP lifecycles before you touch any framework.. that ll be better, coz you will have a good grasp of the inner workings.. Head First Servlets and JSP is the book you should go for..
在触摸任何框架之前,你应该更好地学习基本的servlet和JSP生命周期......那会更好,因为你将很好地掌握内部工作原理。头一个Servlets和JSP是你应该去的书。
#10
I would consider using Groovy on Grails. It's a lot easier to get started and it has a lot of of things that you need built-in. GWT is available via a plugin as is JQuery.
我会考虑在Grails上使用Groovy。入门起来要容易得多,并且它有很多内置的东西。 GWT可以通过插件获得,就像JQuery一样。
The nice thing about Groovy is that it is basically a superset of Java with the great quick start speed of Rails.
Groovy的优点在于它基本上是Java的超集,具有很快的Rails启动速度。
And it will deploy as a .war to your Java EE app server.
它将作为.war部署到您的Java EE应用服务器。
#11
I love the Sam's book, 'Teach yourself J2EE in 21 Days'. Awesome for concept reference and basic syntax. Should be pretty cheap by now too.
我喜欢Sam的书,“在21天内自学J2EE”。非常适合概念参考和基本语法。现在也应该很便宜。
#1
There are so many different Java Enterprise technologies it's pretty hard to know where to start. As previously mentioned, the head first JSP & Servlets book is excellent. I currently work on an Enterprise app that was made years ago with just Servlets. We have migrated over to JSP's as time has gone on but we are not using any of the newer frameworks. So it is for sure a valid way to do it, although dated.
有许多不同的Java Enterprise技术,很难知道从哪里开始。正如前面提到的,头部第一本JSP和Servlets书籍非常出色。我目前正在使用几年前只使用Servlet创建的企业应用程序。随着时间的推移,我们已经迁移到JSP,但我们没有使用任何新的框架。所以它确实是一种有效的方法,尽管已经过时了。
The thing about java, is that most enterprise development is a conjunction of a bunch of different technologies. For example, you could create an app using JSP's for the views with a Servlet back-end, using Hibernate for you DB connections, JDOM for your XML, JUnit for your testing framework, Log4j or AspectJ for your logging framework, Lucene for search, JBoss for deployment (and deployment can be pretty non-trivial) etc. etc. etc. You aren't going to go out and learn all of those technologies in the next 3 days.
关于java的事情是,大多数企业开发是一堆不同技术的结合。例如,您可以使用JSP为使用Servlet后端的视图创建应用程序,使用Hibernate进行数据库连接,使用JDOM进行XML连接,使用JUnit进行测试框架,使用Log4j或AspectJ进行日志记录框架,使用Lucene进行搜索,用于部署的JBoss(以及部署可能非常重要)等等。您不会在接下来的3天内出去学习所有这些技术。
What I would suggest is (as previously mentioned) to pick a framework, and there are many to choose from such as Tapestry, JSF, Wicket, Struts, etc. that will abstract away a lot of the underlying technologies. Any java technology you pick will have a good community behind it willing to help.
我建议(如前所述)选择一个框架,有很多可供选择,如Tapestry,JSF,Wicket,Struts等,它们将抽象出很多底层技术。您选择的任何Java技术都将拥有一个愿意提供帮助的良好社区。
Another thing to consider, since you seem to be in a hurry to get things working, is that (in my opinion at least) Java is not a FAST language to build things in. It is very verbose and unless you grasp the nuances of good Java web design it is very easy to shoot yourself in the foot. Perhaps you should look at some of the other technologies that are available on the JVM (so that you have all the Java libs available) such as Groovy.
另一件需要考虑的事情是,因为你似乎急于让事情发生,所以(至少在我看来)Java并不是一种快速构建内容的语言。它非常冗长,除非你掌握好的细微差别Java网页设计很容易在脚下拍摄自己。也许您应该查看JVM上可用的其他一些技术(以便您拥有所有可用的Java库),例如Groovy。
Groovy allows you the ability to program with Java syntax if you choose, or a dynamic Ruby-like syntax. Additionally, Grails is pretty much a Rails clone for Groovy and will let you write a web app in no time at all.
如果您愿意,Groovy允许您使用Java语法编程,或者使用类似动态的Ruby语法。另外,Grails几乎是Groovy的Rails克隆版,可以让你立刻编写一个Web应用程序。
Whatever you choose to do, good luck and welcome to the wonderful world of Java Web Apps.
无论您选择做什么,祝您好运,欢迎来到Java Web Apps的精彩世界。
#2
You should skip basic servlets and use a web framework, from Struts + Tiles (simple to get to grips with - a few hours at most) to Spring, etc. In your case I would also use Hibernate for database abstraction - you don't get up to speed with JDBC in such a short time.
你应该跳过基本的servlet并使用一个Web框架,从Struts + Tiles(简单到掌握 - 最多几个小时)到Spring等等。在你的情况下我也会使用Hibernate进行数据库抽象 - 你没有在如此短的时间内熟悉JDBC。
#3
As a start, I would recommend you pick up Head First Servlets & JSP. It will give you a nice overview of Java web development. From their you would be better able to pick a web framework to use.
首先,我建议您选择Head First Servlets和JSP。它将为您提供Java Web开发的精彩概述。从他们那里你可以更好地选择一个使用的Web框架。
#4
I'd recommend Matt Raible's app fuse .
我推荐Matt Raible的应用程序保险丝。
It will give you a crash course in hooking your app up to a database, using a mvc framework, as well as some of the java build tools. This App fuse demo will show how quickly he gets things rolling.
它将为您提供一个速成课程,将您的应用程序连接到数据库,使用mvc框架以及一些Java构建工具。这个App保险丝演示将展示他如何快速地推动事物的发展。
#5
For basic simple java based web-app follow below things
对于基本的简单的基于Java的web-app,请遵循以下内容
- Install IDE (eg. eclipse,netbeans)
- Install web/application server (eg. Tomcat/Jboss)
- Configure server in IDE
- Create new dynamic web project with JSP/Servlet
- learn/develop and run sample applications which includes advance technology like Spring,Struts,Hibernate,EJB etc.
安装IDE(例如eclipse,netbeans)
安装Web /应用程序服务器(例如Tomcat / Jboss)
在IDE中配置服务器
使用JSP / Servlet创建新的动态Web项目
学习/开发和运行示例应用程序,其中包括Spring,Struts,Hibernate,EJB等先进技术。
I believe design is more important than technology, so keep learning design patterns. all major frameworks are based on different design pattern.
我相信设计比技术更重要,所以要不断学习设计模式。所有主要框架都基于不同的设计模式。
#6
I would suggest that you try JSP first. JSP is simpler since you don't have to deal with the underlying server technology, not for simple applications atleast. It will get you up to speed. Later, as you gain experience, you can use servlets directly.
我建议你先尝试JSP。 JSP更简单,因为您不必处理底层服务器技术,而不是简单的应用程序。它会让你加快速度。之后,随着经验的积累,您可以直接使用servlet。
It will also fit well with your PHP intuitions.
它也适合您的PHP直觉。
#7
It's true that starting with Java Web development is not as easy as PHP, especially with CodeIgniter, a framework that I've fallen in love with.
确实,从Java Web开发开始并不像PHP那么容易,尤其是CodeIgniter,这是我爱上的框架。
I'd recommend Grails, but first pick up a book on the subject. I've found that in order to get productive quickly you'll need a proper reference. Personally I used The definitive guide to Grails.
我推荐Grails,但首先拿起一本关于这个主题的书。我发现为了快速提高效率,你需要一个适当的参考。就个人而言,我使用了Grails的权威指南。
#8
I would recommend grabbing a copy of the Servlet 2.5 Specification for reference purposes. It's a fairly nice read, and not too dry for a specification.
我建议抓取Servlet 2.5规范的副本以供参考。这是一个相当不错的阅读,并且对于规范来说并不太干。
It explains about Sessions, Filters, Listeners, threading model, etc...
它解释了会话,过滤器,监听器,线程模型等...
Also, take a look at the JSP Model 2 architecture (better link) which explains the best use of servlets and JSPs.
另外,请看一下JSP Model 2架构(更好的链接),它解释了servlet和JSP的最佳用途。
I wouldn't recommend looking at Struts or Spring if you only have a few days to get up to speed from scratch. Once you have gained familiarity with servlets and JSPs, then you could look at Spring MVC for an approach that supports easier unit testing for controllers.
如果你只有几天时间从头开始加速,我不建议你看看Struts或Spring。一旦熟悉了servlet和JSP,就可以看一下Spring MVC,它支持更简单的控制器单元测试。
#9
You should better learn basic servlet and JSP lifecycles before you touch any framework.. that ll be better, coz you will have a good grasp of the inner workings.. Head First Servlets and JSP is the book you should go for..
在触摸任何框架之前,你应该更好地学习基本的servlet和JSP生命周期......那会更好,因为你将很好地掌握内部工作原理。头一个Servlets和JSP是你应该去的书。
#10
I would consider using Groovy on Grails. It's a lot easier to get started and it has a lot of of things that you need built-in. GWT is available via a plugin as is JQuery.
我会考虑在Grails上使用Groovy。入门起来要容易得多,并且它有很多内置的东西。 GWT可以通过插件获得,就像JQuery一样。
The nice thing about Groovy is that it is basically a superset of Java with the great quick start speed of Rails.
Groovy的优点在于它基本上是Java的超集,具有很快的Rails启动速度。
And it will deploy as a .war to your Java EE app server.
它将作为.war部署到您的Java EE应用服务器。
#11
I love the Sam's book, 'Teach yourself J2EE in 21 Days'. Awesome for concept reference and basic syntax. Should be pretty cheap by now too.
我喜欢Sam的书,“在21天内自学J2EE”。非常适合概念参考和基本语法。现在也应该很便宜。