Internet Explorer wants to download the webpage of

2019-05-26 07:50发布

问题:

I am using Netbeans 7.1 with Glassfish 3.1.1, and JDK 6. I built a sample project from a Java EE 5 tutorial. Sample Projects Download, The project is the guessNumber project.

I open the project, assign the glassfish server to it, deploy it and run it. The result is this:

What would cause this? Why doesn't Internet Explorer want to render this as an HTML page and offer to download the file instead? I saved the file. Here it is: guessNumber

I did not change any project settings. I also uninstalled and re-installed Netbeans, Glassfish, and JDK 6 and reinstalled just to be sure nothing got changed in those settings.

回答1:

IE does not support HTML files which are served with content type of application/xhtml+xml.

Change the following line in top of all JSPs

<%@ page contentType="application/xhtml+xml" %>

to

<%@ page contentType="text/html" %>

This was a mistake of the tutorial's authors (or, maybe, a purposeful stab towards IE users that they're using the wrong browser for the web; it works in real browsers like Chrome, Firefox, etc).


Unrelated to the concrete problem, don't use outdated JSF 1.x tutorials/books. Instead use JSF 2.x ones. With JSF 1.x and JSP you're basically working with dead technology. Glassfish 3.x supports JSF 2.x out the box already. JSF 2.x is part of Java EE 6. Concentrate on finding/reading JSF 2.x tutorials/books.

See also:

  • What are the main disadvantages of Java Server Faces 2.0?
  • Is it possible to use JSF+Facelets with HTML 4/5?


回答2:

I got the same issue in IE , my issue fixed by just removing the pageencoding:

 pageEncoding="ISO-8859-1" .`