WebWork框架如何使用,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
十載的圍場網(wǎng)站建設經(jīng)驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。營銷型網(wǎng)站建設的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調(diào)整圍場建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)從事“圍場網(wǎng)站設計”,“圍場網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
1 先下載WebWork框架開發(fā)包http://www.opensymphony.com/webwork/download.action 我用的是2.2.4的.
2 .在WebWork框架里建立一個WEB工程.你解壓WebWork的開發(fā)包以后會發(fā)現(xiàn)有兩個jar文件在***級目錄里面,把他們拷貝進你的工程里面.然后你還會看見lib目錄(webwork開發(fā)支持的所有jar文件),lib目錄下面有個defult的目錄,把這個目錄里面的jar文件也都拷貝進你的工程,他們是開發(fā)webwork最基本的保障.
3 在src下創(chuàng)建兩個文件.
(1)xwork.xml
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd"> <xwork> <include file="webwork-default.xml" /> <package name="webwork" extends="webwork-default"> <action name="hello" class="helloworld.HelloWorldAction"> <result name="yes" type="dispatcher">/yes.jsp </result> </action> </package> </xwork>
(2)webwork.properties
webwork.i18n.encoding=GBK
### Load custom property files (does not override webwork.properties!)
# added the MockTag to the path of Tags that the TagDirective will search through
webwork.velocity.tag.path = com.opensymphony.webwork.views.velocity.ui, org.displaytag.tags
webwork.ui.templateDir = template
### Load custom default resource bundles
### XSLT Cache
webwork.xslt.nocache = true
3 web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XML Schema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <welcome-file-list> <welcome-file>index.jspwelcome-file> welcome-file-list> <servlet> <servlet-name>webworkservlet-name> <servlet-class> com.opensymphony.webwork.dispatcher.ServletDispatcher servlet-class> servlet> <servlet-mapping> <servlet-name>webworkservlet-name> <url-pattern>*.actionurl-pattern> servlet-mapping> web-app>
4 在WebWork框架中創(chuàng)建HelloWorldAction類在helloworld包下,填寫代碼如下:
package helloworld; import com.opensymphony.xwork.Action; public class HelloWorldAction implements Action { private String userName; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String execute() throws Exception { // 處理亂碼 //userName = new String (userName.getBytes("iso-8859-1"),"GBK"); System.out.println(userName); return "yes"; } }
5然后在創(chuàng)建下列兩個jsp頁面.
***個頁面:index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <% 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" c> <meta http-equiv="cache-control" c> <meta http-equiv="expires" c> <meta http-equiv="keywords" c> <meta http-equiv="description" c> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <form action="hello.action" method="post"> <input type="text" name="userName"/> <br> <input type="submit"/> </form> </body> </html>
第二個頁面:yes.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <%@ taglib prefix = "ww" uri = "/webwork" %> <% 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 'yes.jsp' starting page</title> <meta http-equiv="pragma" c> <meta http-equiv="cache-control" c> <meta http-equiv="expires" c> <meta http-equiv="keywords" c> <meta http-equiv="description" c> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> yes. <br> <ww:property value="%{userName}"/> </body> </html>
關于WebWork框架如何使用問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關知識。
當前名稱:WebWork框架如何使用
標題URL:http://chinadenli.net/article46/ppsieg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供電子商務、網(wǎng)頁設計公司、企業(yè)建站、ChatGPT、網(wǎng)站策劃、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)