配置对应的WEB.XML
<?
xml version="1.0" encoding="UTF-8"
?>
<
web-app
version
="2.5"
xmlns
="http://java.sun.com/xml/ns/javaee"
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
<
welcome-file-list
>
<
welcome-file
>
index.jsp
</
welcome-file
>
</
welcome-file-list
>
<
filter
>
<
filter-name
>
jxdoPageFilter
</
filter-name
>
<
filter-class
>
JXDO.WebUI.BasePageFilter
</
filter-class
>
</
filter
>
<
filter-mapping
>
<
filter-name
>
jxdoPageFilter
</
filter-name
>
<
url-pattern
>
*.jsp
</
url-pattern
>
</
filter-mapping
>
<
jsp-config
>
<
taglib
>
<
taglib-uri
>
http://jxdo.webui
</
taglib-uri
>
<
taglib-location
>
/WEB-INF/lib/JXDO.WebUI.jar
</
taglib-location
>
</
taglib
>
<
jsp-property-group
>
<
url-pattern
>
*.jsp
</
url-pattern
>
<
page-encoding
>
utf-8
</
page-encoding
>
</
jsp-property-group
>
</
jsp-config
>
</
web-app
>
编写index.jsp页面
<%
...
@ page language="java" pageEncoding="utf-8"
%>

<%
...
@ taglib prefix="jxui" uri="http://jxdo.webui"
%>
<
jxui:page
codeBehind
="index.java"
/>

<
html
>
<
head
><
title
>
test Page
</
title
></
head
>
<
body
>
<
jxui:form
id
="frmid"
>
<
jxui:textbox
id
="tName"
/>
<
input
type
="button"
value
="submit"
name
="button1"
onclick
="__doPostBack(this.name,'onclick');"
>
</
jxui:form
>

</
body
>
</
html
>
编写后台代码index.java
public
class
index
extends
JXDO.WebUI.BasePage
...
{
protected JXDO.WebUI.TextBox tName;
public void Page_Load()throws Exception
...{
if(!this.isPostBack)this.tName.setText("javasuki代码分离");
} 
public void button1_onclick()throws Exception
...{
this.out.print(this.tName.getText());
}
public void Page_Unload()throws Exception
...{
}
}
本文介绍了一种利用JSP和Java实现代码分离的技术方案,包括配置WEB.XML文件、编写index.jsp页面及对应的Java后台代码。该方案通过使用特定的过滤器和标签库实现了前后端代码的有效分离。
1038

被折叠的 条评论
为什么被折叠?



