在Java中如何实现这一点?(包含一些java回调的博客)

在Java中如何实现这一点?(包含一些java回调的博客),java,content-management-system,Java,Content Management System,我想建立一个网站,它基本上是一个博客,带有一点自定义java代码,可以通过服务器上的ajax调用运行 我最初的想法是用wordpress或drupal或类似的东西构建博客,然后运行一个非常简单的JavaWebApp来接收ajax请求。然而,由于没有Java webapps的经验,我不确定是否有一个框架可以用于这些简单的任务。我也从未使用wordpress/drupal/etc来了解集成这些JavaAjax调用有多容易 然后我想,也许我应该运行一些Java CMS而不是drupal、wordpre

我想建立一个网站,它基本上是一个博客,带有一点自定义java代码,可以通过服务器上的ajax调用运行

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

然后我想,也许我应该运行一些Java CMS而不是drupal、wordpress等。这应该允许我轻松地集成ajax挂钩。但是,我没有任何Java CMS的经验来知道哪一个会工作得很好


有Java webapp经验的人能给出他们的推荐吗?

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

如果要使用Wordpress或Drupal,您希望在Java中做哪些在PHP中无法完成的事情

Wordpress很容易安装。如果您有任何web应用程序的经验和PHP的次要知识,那么您不应该有任何问题

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

一个要考虑的是,您的Ajax调用将需要与您的CMS在同一个域上进行。如果要创建两个独立的web应用程序,则它们需要显示在同一个域上


在不知道您的具体需求是什么的情况下给出详细的建议有点困难,但我希望这能有所帮助。

我认为您不应该使用任何框架。只需创建一个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("&nbsp; Hello Oracle World &nbsp;</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();
  }
}
import java.io.*;
//servlet的包
导入javax.servlet.*;
导入javax.servlet.http.*;
公共类HelloWorld扩展了HttpServlet{
/**
*初始化servlet。该方法由
*Java Web服务器加载servlet时。init()方法应保存
*ServletConfig对象,以便getServletConfig()可以返回它
*方法。
*/
public void init(ServletConfig config)抛出ServletException{
super.init(config);
}
/**
*方法来处理HTTP GET请求。在该方法中,一个简单的HTML页面
*显示“Hello OracleWorld”是构建并呈现给用户的。
*doGet()方法的参数为
*1)HttpServletRequest对象,它封装了来自客户端的数据
*2)HttpServletResponse对象,它封装了对客户端的响应
**/
公共无效数据集(HttpServletRequest p_req,HttpServletResponse p_res)
抛出ServletException、IOException{
//设置响应的内容类型
p_res.setContentType(“文本/html”);
//创建ServletOutputStream以写入输出
ServletOutputStream l_out=p_res.getOutputStream();
//使用ServletOutputStream在中打印Hello Oracle World字符串
//HTML页面
l_out.println(“你好,甲骨文世界”);
l_out.println(“

”); l_out.println(“”); l_out.println(“”); l_out.println(“”); l_out.println(“你好,甲骨文世界”); l_out.println(“”); l_out.close();//关闭ServletOutputStream } /** *重写应该返回信息的getServletInfo()方法 *关于Servlet,例如Servlet名称、版本、作者和版权 *注意,这不是HelloWorldservlet函数所必需的,但是 *可以为看到 *在Web服务器的管理工具中返回文本。 **/ 公共字符串getServletInfo(){ 返回“Hello World servlet 1.0 by Reghu”; } 公共空间销毁(){ super.destroy(); } }
如果您没有Java Web应用程序或Java CMS方面的经验,为什么要在Java中这样做?