错误:此XML文件似乎没有与之关联的任何样式信息

时间:2022-03-05 16:57:59

UPDATE: Why is it that when I use google chrome I get the error message, while when I use Windows Explorer, it will display everything fine.

更新:为什么当我使用谷歌浏览器时,我收到错误消息,而当我使用Windows资源管理器时,它会显示一切正常。

I use google chrome to run my web server. I get the following error: I am unsure why I am getting this error, i have the files in the correct areas.

我使用谷歌浏览器来运行我的网络服务器。我收到以下错误:我不确定为什么我收到此错误,我有正确的区域中的文件。

This XML file does not appear to have any style information associated with it. The document tree is shown below.

此XML文件似乎没有与之关联的任何样式信息。文档树如下所示。

<?xml version="1.0"?>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">


   <servlet>
      <servlet-name>news-feed</servlet-name>
      <servlet-class>publisher.web.NewsFeedServlet</servlet-class>
   </servlet>


   <servlet-mapping>
      <servlet-name>news-feed</servlet-name>
      <url-pattern>/news.rss</url-pattern>
   </servlet-mapping>


</web-app>

Here is how my files are structured

这是我的文件的结构

错误:此XML文件似乎没有与之关联的任何样式信息

NewsFeedServlet.java

public class NewsFeedServlet extends HttpServlet
{
    private Logger logger = Logger.getLogger(this.getClass());

    @Override
    public void init(ServletConfig config) throws ServletException
    {
           logger.debug("init()");
           try 
           {
               Class.forName("com.mysql.jdbc.Driver");
           } 
           catch (ClassNotFoundException e)
           {
               throw new ServletException(e);
           }
    }



    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException
    {

        SyndFeed feed = new SyndFeedImpl();
        feed.setFeedType("rss_2.0");
        feed.setTitle("My Local News Feed");
        feed.setLink("http://localhost:8080/publisher/");
        feed.setDescription("This feed was created using ROME.");
        List<SyndEntry> entries = new ArrayList<SyndEntry>();

        try
        {
            Connection connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost/publisher", "publisher",
                    "publisher");
            Statement statement = connection.createStatement();
            ResultSet resultSet = statement
                    .executeQuery("select * from news_item;");
            while (resultSet.next())
            {
                String title = resultSet.getString("title");
                String url = resultSet.getString("url");
                SyndEntry entry = new SyndEntryImpl();
                entry.setTitle(title);
                entry.setLink(url);
                entries.add(entry);
            }
            connection.close();
        }
        catch (SQLException e)
        {
            throw new ServletException(e);
        }

        resp.setContentType("text/xml");

        feed.setEntries(entries);
        Writer writer = resp.getWriter();
        SyndFeedOutput output = new SyndFeedOutput();
        try
        {
            //Send response to output stream
            output.output(feed, writer);
        } 
        catch (FeedException e)
        {
            logger.error("", e);
        }
    }

Publisher log:

2015-05-02 15:35:45,550 [http-nio-8080-exec-1] DEBUG publisher.web.NewsFeedServlet - init()
2015-05-02 15:41:08,137 [http-nio-8080-exec-4] DEBUG publisher.web.NewsFeedServlet - init()

1 个解决方案

#1


Chrome does not have rss reader implemented. You need to install extension. There are several out there.

Chrome没有实现rss阅读器。您需要安装扩展程序。那里有好几个。

#1


Chrome does not have rss reader implemented. You need to install extension. There are several out there.

Chrome没有实现rss阅读器。您需要安装扩展程序。那里有好几个。