❶ 讲java代码嵌入html
你要先想好怎么送给她。要是让她访问你的网站,可以在jsp页中加入java代码放在tomcat上发布。如果你直接给她优盘,html中的java将无法正确显示。
❷ 如何吧html语言嵌套在java中
应该是把java代码嵌入到 html 中 jsp: <%@ 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 'buy.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> <% request.setCharacterEncoding("utf-8"); String proctName=request.getParameter("proctName"); int proctNum=Integer.parseInt("proctNum"); Object obj=session.getAttribute(proctName); if(obj!=null){ int oldNum=((Integer)obj).intValue(); proctNum+=oldNum; session.setAttribute(proctName, proctNum); }else{ session.setAttribute(proctName, proctNum); } %> 购物成功 <a href="show.jsp">查看购物车</a> <a href="index.jsp">继续购物</a> <% %> </body> </html> 不能实现功能哈 只是给你看看结构
希望采纳
❸ 怎样把java代码放到html中
一般java是可以嵌入jsp页面的,当然也可以调用外部的java。jsp页面要想运行必须放到容器里,例如最流行的tomcat。
最后可以把jsp就是用java程序动态生成html页面,浏览器不能解析java代码,所以tomcat这种服务器负责解析,生成最终的html,希望能帮到你!
❹ 如何把java小程序放到html网页中运行
建立一个和你类名一样的HTML文本比如c1_2.java
建立文本名就叫c1_2.html
然后在文本中输入<APPLET CODE="c1_2.class"width=150 height=100></APPLET>
width和height是你打开applet应用小程序浏览器窗口的宽度和长度
c1_2.class是在cmd下用javac编译c1_2.java出来的。
所以在cmd中找对象的子目录 输入javac xxx编译 回车 aapletviwer xxxx就行了
求采纳
❺ java注释文档的 嵌入式html
看过java API么?那个文档就是根据嵌入式html生成的,什么叫嵌入式html?就是把html嵌入到了java源文件中
作用就不用明说了,如果没有java api,写代码是多么的痛苦!
/**
* The <code>String</code> class represents character strings. All
* string literals in Java programs, such as <code>"abc"</code>, are
* implemented as instances of this class.
* <p>
* Strings are constant; their values cannot be changed after they
* are created. String buffers support mutable strings.
* Because String objects are immutable they can be shared. For example:
* <p><blockquote><pre>
* String str = "abc";
* </pre></blockquote><p>
* is equivalent to:
* <p><blockquote><pre>
* char data[] = {'a', 'b', 'c'};
* String str = new String(data);
* </pre></blockquote><p>
* Here are some more examples of how strings can be used:
* <p><blockquote><pre>
* System.out.println("abc");
* String cde = "cde";
* System.out.println("abc" + cde);
* String c = "abc".substring(2,3);
* String d = cde.substring(1, 2);
* </pre></blockquote>
* <p>
* The class <code>String</code> includes methods for examining
* indivial characters of the sequence, for comparing strings, for
* searching strings, for extracting substrings, and for creating a
* of a string with all characters translated to uppercase or to
* lowercase. Case mapping is based on the Unicode Standard version
* specified by the {@link java.lang.Character Character} class.
* <p>
* The Java language provides special support for the string
* concatenation operator (+), and for conversion of
* other objects to strings. String concatenation is implemented
* through the <code>StringBuilder</code>(or <code>StringBuffer</code>)
* class and its <code>append</code> method.
* String conversions are implemented through the method
* <code>toString</code>, defined by <code>Object</code> and
* inherited by all classes in Java. For additional information on
* string concatenation and conversion, see Gosling, Joy, and Steele,
* <i>The Java Language Specification</i>.
*
* <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
*
* <p>A <code>String</code> represents a string in the UTF-16 format
* in which <em>supplementary characters</em> are represented by <em>surrogate
* pairs</em> (see the section <a href="Character.html#unicode">Unicode
* Character Representations</a> in the <code>Character</code> class for
* more information).
* Index values refer to <code>char</code> code units, so a supplementary
* character uses two positions in a <code>String</code>.
* <p>The <code>String</code> class provides methods for dealing with
* Unicode code points (i.e., characters), in addition to those for
* dealing with Unicode code units (i.e., <code>char</code> values).
*
* @author Lee Boynton
* @author Arthur van Hoff
* @version 1.188, 09/14/04
* @see java.lang.Object#toString()
* @see java.lang.StringBuffer
* @see java.lang.StringBuilder
* @see java.nio.charset.Charset
* @since JDK1.0
*/
这是java String类开始的一段文档,看里面用了很多html标签,所谓嵌入式html也
❻ 怎么把java程序嵌入到HTML文档中
<appletcode="Bubbles.class"width="350"height="350">
</applet>
不过这种技术不建议学了,不太好用。
另外,在html5中,已经不支持applet标签了,用object代替。
❼ java:嵌入式HTML详解
Java是由Sun微系统公司所发展出来的程序语言,它本身是一种对象导向(Object-Oriented)的程序语言。JAVA目前在手机上应用最多的就是JAVA游戏。
Java也号称是能跨平台使用的语言,这主要是因为Java本身被编译之后,并不是直接产生可执行的码,而是产生一种中间码叫作 ByteCode,这种码必需在透过 Java 的直译器来解读它,才能够真正的被执行,所以只要平台上装有这种Java的直译器,就能解读ByteCode也就能执行Java编译过的程序,故与Java程序是在那种平台上被编译的,就完全没有干系了。Java写出来的程序可分为两类,分别是Java Applet与一般的Application,而Application 这一类就与一般的程序如C++的作用是比较类似的,是一个独立可执行的应用程序,像HotJava是一个浏览器,且就是使用Java程序所发展出来的。最常见的Java程序包括应用程序和applets。应用程序是单独的程序,诸如HotJava浏览器软件就是用Java语言编写的。 Applets类似于应用程序,但是它们不能单独运行, Applets可以在支持Java的浏览器中运行。Applet主要是内置于HTML网页中,在浏览时发挥作用。
Java的目标是为了满足在一个充满各式各样不同种机器,不同操作系统平台的网络环境中开发软件。利用Java程序语言,可以在网页中加入各式各样的动态效果。可以放上一段动画,加入声音,也可以建立交互式网页等。
Java手机软件平台
Java手机软件平台采用的基本Java平台是CLDC (Connected Limited Device Configuration)和MIDP (Mobile Information Device Profile),是J2ME (Java 2 Micro Edition)的一部分,在中国一般称为“无线Java”技术。此前,有人把它叫做“K-Java”;其实,K-Java的叫法只是Sun公司在开发KVM Java虚拟机时的项目代号,在该技术被正式命名为KVM后,就不再用K-Java了。
KJava即J2ME(Java 2 Micro Edition),是Sun公司专门用于嵌入式设备的Java软件。以KJava编程语言为手机开发应用程序,可以为手机用户提供游戏、个人信息处理、电子地图、股票等服务程序。J2ME(Java 2 Micro Edition)是致力于消费产品和嵌入式设备的最佳解决方案。J2ME在设计其规格的时候,遵循着“对于各种不同的装置而造出一个单一的开发系统是没有意义的事”这个基本原则。于是J2ME先将所有的嵌入式装置大体上区分为两种:一种是运算功能有限、电力供应也有限的嵌入式装置(比方说PDA、手机);另外一种是运算能力相对较佳、并且在电力供应上相对比较充足的嵌入式装置(比方说冷气机、电冰箱)。因为这两种区分,所以Java引入了一个叫做Configuration的概念,然后把上述运算功能有限、电力有限的嵌入式装置定义在Connected Limited Device Configuration(CLDC)规格之中;而另外一种装置则规范为Connected Device Configuration(CDC)规格。也就是说,J2ME先把所有的嵌入式装置利用Configuration的概念区隔成两种抽象的型态。
Java技术的开放性、安全性和庞大的社会已有资源,以及其跨平台性,即“编写一次,到处运行”的特点,使Java技术成为智能手机软件平台的事实标准。采用Java技术后,编写应用程序和提供服务的人就不必关心接受其服务的手机采用的是什么操作系统和芯片,只要按照Java的要求去写程序就好了;同样,生产手机的厂商也不必顾虑将来谁来提供增值服务。可以看出,采用Java技术,可以建立完整、高效的无线数据增值服务产业链,从而为用户提供灵活、个性化、内容方式多样的服务。
❽ html嵌入java代码怎么用
在html中加入java代码,就是jsp页面,jsp里可以加入java代码了,当然也可以调用外部的java。jsp页面要想运行必须放到容器里,例如最流行的tomcat。
你应该是新手,还不明白概念,所以在网上找些视频教程看吧,搜索j2ee或者jsp的教程,jsp就是用java程序动态生成html页面,浏览器不能解析java代码,所以tomcat这种服务器负责解析,生成最终的html