我该如何在 Java 中做到这一点? (一个带有一些java回调的博客)

发布于 2024-10-07 03:50:32 字数 401 浏览 0 评论 0原文

我想构建一个基本上是一个博客的网站,其中包含一些自定义 java 代码,可通过服务器上的 ajax 调用运行。

我最初的想法是用 wordpress 或 drupal 或类似的东西构建博客,然后运行一个非常简单的 java web 应用程序来接收 ajax 请求。然而,由于没有 Java Web 应用程序的经验,我不确定是否有一个框架可以用于此类简单的任务。我也没有使用过 wordpress/drupal/etc 来了解集成这些 java ajax 调用是多么容易。

然后我想,也许我应该运行一些 Java CMS,而不是 drupal、wordpress 等。这应该可以让我轻松集成我的 ajax 挂钩。但同样,我没有使用任何 Java CMS 的经验,不知道哪种效果最好。

有一些 Java Web 应用程序经验的人可以给出建议吗?

I want to build a website that is basically a blog with a little bit of custom java code to be run via ajax calls on the server.

My initial thoughts were to build the blog in wordpress or drupal or something similar, then run a very simple java webapp to receive the ajax requests. However, having no experience with Java webapps, I am not sure of a framework made for such simple tasks. Nor have I ever used wordpress/drupal/etc to know how easy it would be to integrate these java ajax calls.

Then I thought, perhaps I should just run some Java CMS instead of drupal, wordpress, etc. This should allow me to easily integrate my ajax hooks. But again, I have no experience with any Java CMS's to know which would work well.

Can someone with some Java webapp experience give their recommendation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

唱一曲作罢 2024-10-14 03:50:32

我在两篇文章中第二次提出了相同的建议(!),但也许看看 Liferay 门户服务器的免费社区版?它在 Java 上运行(在 tomcat+mysql 上很容易),并包含博客和 CMS 以及其他功能。还可以选择修改源代码(根据许可证)以添加您的自定义行为。

Second time in two posts I have made the same recommendation (!) but maybe look at the free Community edition of Liferay portal server? It runs on Java (easy on tomcat+mysql) and has blogs and CMS and other features included. There is also the option of modifying the source code (subject to the license) to add your custom behaviour.

鼻尖触碰 2024-10-14 03:50:32

如果您要使用 Wordpress 或 Drupal,您究竟希望在 Java 中实现哪些在 PHP 中无法实现的功能?

WordPress 的设置相当容易。如果您有任何 Web 应用程序经验并且对 PHP 略知一二,那么您应该不会有任何问题。

Spring MVC 是一个相当简单的 Java Web 应用程序框架。您可以相对轻松地在 Google App Engine 上运行它,并且在线有大量文档/支持。

需要考虑的一件事是,您的 AJAX 调用需要对您的 CMS 所在的同一域进行。如果您要创建两个单独的 Web 应用程序,那么它们需要显示在同一域中。

不知道您的具体要求是什么,很难给出任何详细的建议,但我希望这对您有所帮助。

What exactly are you looking to do in Java that you couldn't accomplish in PHP if you were to use Wordpress or Drupal?

Wordpress is rather easy to setup. If you have any web app experience at all and minor knowledge of PHP then you shouldn't have any problems.

Spring MVC is a fairly straightforward Java web app framework. You can run it on Google App Engine with relative ease and there's a lot of documentation / support online.

One thing to consider is that your AJAX calls will need to be made to the same domain that your CMS is on. If you're creating two separate web apps then they need to appear to be on the same domain.

It's a bit difficult to give any detailed advice not knowing what your particular requirements are but I hope this helped a little.

情泪▽动烟 2024-10-14 03:50:32

我认为你不应该使用任何框架。只需创建一个 servlet 即可。因为即使你使用了框架,你仍然要了解servlet是什么。这些代码来自 Oracle 的 站点,修改doGet来进行您的处理。或者你可以将其更改为 doPost。

    import java.io.*;

// Packages for Servlets
import javax.servlet.*;
import javax.servlet.http.*;


public class HelloWorld extends HttpServlet {

  /**
  * Initializes the servlet. The method is called once, automatically, by the
  * Java Web Server when it loads the servlet. The init() method should save
  * ServletConfig object so that it can be returned by the getServletConfig()
  * method.
  */
  public void init(ServletConfig config) throws ServletException {

    super.init(config);
  }

  /**
  * Method to process HTTP GET requests. In this method a Simple HTML page
  * displaying "Hello Oracle World" is built and presented to user.
  * The parameters of doGet() method is
  * 1) HttpServletRequest object, which encapsulates the data from the client
  * 2) HttpServletResponse object, which encapsulates the response to the client
  **/

  public void doGet(HttpServletRequest p_req, HttpServletResponse p_res)
                                        throws ServletException, IOException {

    // Sets the content type of the response
    p_res.setContentType("text/html");

    // Create a ServletOutputStream to write the output
    ServletOutputStream l_out = p_res.getOutputStream();

    // Use ServletOutputStream to print the Hello Oracle World String in
    // the HTML page

    l_out.println("<HTML><HEAD><TITLE>Hello Oracle World</TITLE></HEAD>");
    l_out.println("<BODY BGCOLOR =\"lightgrey\"><CENTER><BR><BR>");
    l_out.println("<TABLE BORDER=4 BGCOLOR =\"blue\">");
    l_out.println("<TR><TD align =\"center\" valign=\"center\" >");
    l_out.println("<FONT face=\"Arial,helvetica\" color =red size=5>");
    l_out.println("  Hello Oracle World  </FONT></TD></TR></TABLE>");
    l_out.println("</BODY></HTML>");

    l_out.close(); // Close the ServletOutputStream
  }

  /**

  * Override the getServletInfo() method which is supposed to return information
  * about the Servlet, e.g. the servlet name, version, author and copyright
  * notice. This is not required for the function of the HelloWorld servlet but
  * can provide valuable information to the user of a servlet who sees the
  * returned text in the administration tool of the Web Server.
  **/
  public String getServletInfo() {
    return "Hello World servlet 1.0 by Reghu";
  }

  public void destroy() {
     super.destroy();
  }
}

I think you shouldn't use any framework. Just create a servlet. Because even if you use a framework, you still have to understand what a servlet is. These code are from oracle's site, modify doGet to do your processing. Or you could change it to doPost.

    import java.io.*;

// Packages for Servlets
import javax.servlet.*;
import javax.servlet.http.*;


public class HelloWorld extends HttpServlet {

  /**
  * Initializes the servlet. The method is called once, automatically, by the
  * Java Web Server when it loads the servlet. The init() method should save
  * ServletConfig object so that it can be returned by the getServletConfig()
  * method.
  */
  public void init(ServletConfig config) throws ServletException {

    super.init(config);
  }

  /**
  * Method to process HTTP GET requests. In this method a Simple HTML page
  * displaying "Hello Oracle World" is built and presented to user.
  * The parameters of doGet() method is
  * 1) HttpServletRequest object, which encapsulates the data from the client
  * 2) HttpServletResponse object, which encapsulates the response to the client
  **/

  public void doGet(HttpServletRequest p_req, HttpServletResponse p_res)
                                        throws ServletException, IOException {

    // Sets the content type of the response
    p_res.setContentType("text/html");

    // Create a ServletOutputStream to write the output
    ServletOutputStream l_out = p_res.getOutputStream();

    // Use ServletOutputStream to print the Hello Oracle World String in
    // the HTML page

    l_out.println("<HTML><HEAD><TITLE>Hello Oracle World</TITLE></HEAD>");
    l_out.println("<BODY BGCOLOR =\"lightgrey\"><CENTER><BR><BR>");
    l_out.println("<TABLE BORDER=4 BGCOLOR =\"blue\">");
    l_out.println("<TR><TD align =\"center\" valign=\"center\" >");
    l_out.println("<FONT face=\"Arial,helvetica\" color =red size=5>");
    l_out.println("  Hello Oracle World  </FONT></TD></TR></TABLE>");
    l_out.println("</BODY></HTML>");

    l_out.close(); // Close the ServletOutputStream
  }

  /**

  * Override the getServletInfo() method which is supposed to return information
  * about the Servlet, e.g. the servlet name, version, author and copyright
  * notice. This is not required for the function of the HelloWorld servlet but
  * can provide valuable information to the user of a servlet who sees the
  * returned text in the administration tool of the Web Server.
  **/
  public String getServletInfo() {
    return "Hello World servlet 1.0 by Reghu";
  }

  public void destroy() {
     super.destroy();
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文