错误:此 XML 文件似乎没有与之关联的任何样式信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30006832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR: This XML file does not appear to have any style information associated with it
提问by jssmkp
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
这是我的文件的结构


NewsFeedServlet.java
新闻FeedServlet.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()
回答by ohkts11
“This XML file does not appear to have any style information associated with it.” itself is not a problem in most cases. It just states response lacks stylesheet, so browser only shows raw XML.
“这个 XML 文件似乎没有任何与之相关的样式信息。” 在大多数情况下,它本身不是问题。它只是说明响应缺少样式表,因此浏览器仅显示原始 XML。
If you are debugging something and encountered this page, the real issue is not related to this warning usually. Check what is written inside XML and google it without the term “This XML file does not appear~” may solve your issue.
如果您正在调试某些内容并遇到此页面,则真正的问题通常与此警告无关。检查 XML 中写的内容,并在没有术语“此 XML 文件未出现〜”的情况下使用谷歌搜索可能会解决您的问题。
回答by nemcaninz
Chrome does not have rss reader implemented. You need to install extension. There are several out there.
Chrome 没有实现 rss 阅读器。您需要安装扩展程序。那里有几个。

