Java 无法运行简单的";你好,世界&引用;使用NetBeans IDE 8.1和Glassfish 4.1的项目
我是春天的初学者。尝试使用NetBeans IDE 8.1和Glassfish 4.1运行一个简单的“Hello World!”项目 这是我的密码: web.xmlJava 无法运行简单的";你好,世界&引用;使用NetBeans IDE 8.1和Glassfish 4.1的项目,java,spring,jsp,netbeans,glassfish,Java,Spring,Jsp,Netbeans,Glassfish,我是春天的初学者。尝试使用NetBeans IDE 8.1和Glassfish 4.1运行一个简单的“Hello World!”项目 这是我的密码: web.xml <?xml version="1.0" encoding="UTF-8"?> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/appl
<?xml version="1.0" encoding="UTF-8"?>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>tryspring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>tryspring</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
有谁能帮忙吗
此代码也是由NetBeans IDE生成的。我刚刚将dispatcher修饰符从
*.htm
修改为*.jsp
。这是问题的根源吗?您的代码并不重要。错误消息中提到的重定向不存在。请注意,重定向只是浏览器端,若要在服务器端执行重定向,则需要使用“转发”
RequestDispatcher rd = request.getRequestDispatcher("your file.js");
rd.forward(request, response);
服务器日志中有错误吗?(您将在Netbeans输出视图的特定选项卡中找到)@Gimby没有此类错误,而是没有错误。。。。服务器日志中是否有任何输出表明服务器已成功启动?我也会在这里发布日志输出。另外,运行应用程序时浏览器窗口中有哪个URL?
</head>
<body>
<p>Hello! This is the default welcome page for a Spring Web MVC project.</p>
<p><i>To display a different welcome page for this project, modify</i>
<tt>index.jsp</tt> <i>, or create your own welcome page then change
the redirection in</i> <tt>redirect.jsp</tt> <i>to point to the new
welcome page and also update the welcome-file setting in</i>
<tt>web.xml</tt>.</p>
</body>
Error: "HTTP Status 404 - Not Found"
RequestDispatcher rd = request.getRequestDispatcher("your file.js");
rd.forward(request, response);