javascript代码实例教程-基于struts环境下的jquery easyui环境搭建

发布时间:2019-02-01 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-基于struts环境下的jquery easyui环境搭建脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

下载地址:

https://download.csdn.net/detail/cyberzhaohy/7348451

添加了json包:jackson-all-1.8.5.jar,项目结构如下:

<img src="<%=basePath%>/uploaDFile/Collfiles/20140515/20140515090646133.jpg" alt="基于struts环境下的jquery easyui环境搭建">

测试网址:

https://localhZ"/kf/ware/vc/" target="_blank" class="keylink">vc3Q6OTA5MC9qcXVLCnktZWFzeXVpLTEuMi42QmFzZWRvblN0cnV0cy9sYXlvdXQuanNwPC9wPgo8cD7Qp7n7zbzI58/Co7o8YnI+CjwvcD4KPHA+PGltZyBzcmM9"/uploadfile/Collfiles/20140515/20140515090646134.jpg" alt="/">

配置文件web.XMl:

xMLns:xsi="https://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="https://java.sun.COM/xml/ns/j2ee

https://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

index.jsp

org.sPRingframework.web.context.ContextLoaderListener

contextconfigLocation

classpath:beans.xml

oPEnSessionInView

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter

sessionFactoryBeanName

sf

openSessionInView

/*

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2

/*

beans.xml配置,上面配置文件黄色代码sf使用下面黄色代码配置:

xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"

xmlns:context="https://www.springframework.org/schema/context"

xmlns:aop="https://www.springframework.org/schema/aop"

xmlns:tx="https://www.springframework.org/schema/tx"

xsi:schemaLocation="https://www.springframework.org/schema/beans

https://www.springframework.org/schema/beans/spring-beans-2.5.xsd

https://www.springframework.org/schema/context

https://www.springframework.org/schema/context/spring-context-2.5.xsd

https://www.springframework.org/schema/aop

https://www.springframework.org/schema/aop/spring-aop-2.5.xsd

https://www.springframework.org/schema/tx

https://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

classpath:jdbc.properties

class="org.apache.commons.dbcp.BasicDataSource"

destroy-method="close">

value="${jdbc.driverclassname}"/>

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

com.xdy.registration.model

org.hibernate.dialect.oracleDialect

true

class="org.springframework.orm.hibernate3.HibernateTemplate">

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

expression="execution(public* com.xdy.registration.service.*.*(..))">

advice-ref="txAdvice"/>

控制逻辑struts.xml配置:

class="com.xdy.registration.action.UserAction">

/registerSuccess.jsp

/registerFail.jsp

/UserList.jsp

/User.jsp

UserAction.java代码如下:

package com.xdy.registration.action;

import java.io.IOException;

import java.io.StringWriter;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import org.codehaus.jackson.JsonFactory;

import org.codehaus.jackson.JsonGenerator;

import org.codehaus.jackson.map.ObjectMapper;

import com.opensymphony.xwork2.ActionSupport;

import com.opensymphony.xwork2.ModelDriven;

import com.xdy.registration.model.MyUser;

import com.xdy.registration.service.UserManager;

import com.xdy.registration.vo.UserRegisterInfo;

//@component("user")

//@Component("u")

//@Scope("prototype")

publicclass UserAction extends ActionSupport implements ModelDriven {

public Object getModel() {

// TODO Auto-generatedmethod stub

returninfo;

}

/*

* private Stringusername;; private String password; private String

* password2;

*

* public StringgetUsername() { return username; }

*

* public voidsetUsername(String username) { this.username = username; }

*

* public StringgetPassword() { return password; }

*

* public voidsetPassword(String password) { this.password = password; }

*

* public StringgetPassword2() { return password2; }

*

* public voidsetPassword2(String password2) { this.password2 = password2; }

*/

private UserRegisterInfo info = new UserRegisterInfo();

private UserManager userManager;

private List users;

private MyUser myUser;

public MyUser getMyUser() {

returnmyUser;

}

publicvoid setMyUser(MyUser myUser) {

this.myUser = myUser;

}

public String list() {

this.users = this.userManager.getUsers();

return"list";

}

public List getUsers() {

returnusers;

}

publicvoid setUsers(List users) {

this.users = users;

}

public UserAction() {

System.out.println("useractioncreated!");

}

/*

* public UserAction() {ApplicationContext ctx = new

*ClassPathXmlApplicationContext("beans.xml"); um = (UserManager)

*ctx.getBean("userManager"); }

*/

@override

public String execute() throws Exception {

System.out.println(info.getUsername());

/*

* if (password !=password2) { return "fail"; }

*/

MyUser u = new MyUser();

u.setUsername(info.getUsername());//username);

u.setPassword(info.getPassword());//password);

if (userManager.exists(u)) {

return"fail";

}

userManager.add(u);

return"success";

}

publicvoid datagird() {

list();

wrITeJson(this.users);

}

publicvoid writeJson(Object o) {

String json=getJsonString(o);

try{

ServletActionContext.getResponse().getWriter().write(json);

}catch(IOException e){

e.printStackTrace();

}

}

public String getJsonString(Object o) {

ObjectMapper om=new ObjectMapper();

StringWriter sw=new StringWriter();

try{

JsonGenerator jg=new JsonFactory().createjsonGenerator(sw);

om.writeValue(jg, o);

jg.close();

}

catch(IOException e){

e.printStackTrace();

}

return sw.toString();

}

public UserManager getUserManager() {

returnuserManager;

}

publicvoid setUserManager(UserManager userManager) {

this.userManager = userManager;

}

public UserRegisterInfo getInfo() {

returninfo;

}

publicvoid setInfo(UserRegisterInfo info) {

this.info = info;

}

public String load() {

this.myUser = this.userManager.loadById(info.getId());

return"load";

}

}

界面调用layout.jsp代码:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme() &#43; "://"

+ request.getServerName() + ":" + request.getServerPort()

+ path + "/";

%>

My JSP'layout.jsp' starting page

<script type="text/javascript" src="js/jquery-1.7.2.min.js" charset="UTF-8"></script>

<script type="text/javascript" src="js/jquery.easyui.min.js" charset="UTF-8"></script>

type="text/css">

<script type="text/javascript" src="js/locale/easyui-lang-zh_CN.js" charset="UTF-8"></script>

<script charset="UTF-8">

VAR cc;

$(function(){

cc = $('#cc').layout();

cc.layout('collapse','west');

});

function getcenterPanel(){

var centerPanel=$('#cc').layout('panel','center');

console.info(centerPanel.panel('options').title);

}

</script>

style="height:100px;">

style="height:100px;">

style="width:200px;">

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦!&nbsp;js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-基于struts环境下的jquery easyui环境搭建全部内容,希望文章能够帮你解决javascript代码实例教程-基于struts环境下的jquery easyui环境搭建所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。