日期:2014-05-17  浏览次数:20764 次

新手求教怎么输出helloword?
用myeclipse 10 新建一个jsp页面

HTML code


<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
  
  <body>
  <%  System.out.println ("helloworld"); %>为什么这里没有输出?
    This is my JSP page. <br>
  </body>
</html>





------解决方案--------------------
jsp内置对象out

直接使用out.print();
------解决方案--------------------
1.你用System.out.println();这个是在控制台打印。所以页面上不会有

<%out.print("hello world");%>这个是表示在页面上输出hello world字符
------解决方案--------------------
探讨

改了一样没有任何输出啊

------解决方案--------------------
探讨

1.你用System.out.println();这个是在控制台打印。所以页面上不会有

<%out.print("hello world");%>这个是表示在页面上输出hello world字符

------解决方案--------------------
直接写个hello world就行了啊,,

------解决方案--------------------

------解决方案--------------------
方法1
HTML code

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
  
  <body>
  <%  out.println ("helloworld"); %>
    This is my JSP page. <br>
  </body>
</html>

------解决方案--------------------
探讨

HTML code

<% System.out.print ("helloworld"); //这个不会输出