网页按钮中的文字从文件中读取

来源:百度知道 编辑:UC知道 时间:2024/06/02 13:06:49
<input type="button" value="提交" onclick="mm()">
<script>
function mm()
{
alert("测试");
}
</script>

现在这个按钮显示的是"提交",我现在想让它显示的内容是读取的文档中的文字,如何设置?
不懂啊。我没受过java,jsp之类正规教育。能给个代码不?

用struts来做嘛,写个资源文件
ApplicationResources.properties
button.submit=submit

ApplicationResources_zh_CN.properties
button.submit=\u63d0\u4ea4

struts-config.xml中
<message-resources parameter=".../resources/ApplicationResources" />

<input type="button" value='<bean:message key="button.submit" />' onclick="mm()">

我把后台的读取文本代码给你把。
/**
* 读取文件
*
* @param file
*/
public void fileRead() {
FileReader fileRead = null;
BufferedReader buRead = null;
try {
//你读取的文件路径。不要写错了哦。。
fileRead = new FileReader(new File("D:/test.txt"););
buRead = new BufferedReader(fileRead);
try { //读取的时候按一行一行的读取
String str = buRead.readLine();
while (str != null) {
//打印出读取到的结果。
System.out.println(str);
str