dwr框架java解析excel_springmvc和DWR的整合

首先定义运行环境:

jdk:1.8

tomcat:8.5.11

spring:4.3.9

mybatis:3.4.4

mybatis-spring:1.3.0

dwr:3.0

注意此处的问题!!

若要使用dwr与spring整合的形式(dwr.xml文件废除,整合至spring的application配置文件中)参考:参考博客,需要将spring的版本降至spring3.x.x,因为dwr组件并不支持spring4.x.x以上的版本。错误信息如下:

Java.lang.NoSuchMethodError:

org.springframework.util.ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;

配置web.xml文件

dwr

org.directwebremoting.servlet.DwrServlet

debug

true

dwr

/dwr/*

配置dwr.xml文件

配置applicationContext-service.xml文件

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"

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

xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

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

http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd

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

http://www.springframework.org/schema/context/spring-context-3.2.xsd

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

http://www.springframework.org/schema/aop/spring-aop-3.2.xsd

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

http://www.springframework.org/schema/tx/spring-tx-3.2.xsd " >

编写dwrController

package com.alex.ssm.controller;

import com.alex.ssm.po.UsersPlus;

import com.alex.ssm.service.impl.UserService;

import org.directwebremoting.annotations.RemoteMethod;

import org.directwebremoting.annotations.RemoteProxy;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import java.util.List;

/**

* Created by Alex on 2017/7/3.

* dwr的controller类

*/

@Controller

//需要标识为RemoteProxy才能被dwr调用

@RemoteProxy

public class DwrController {

@Autowired

private UserService userService;

//查找所有用户

@RemoteMethod

public List getAllUsers() throws Exception{

return userService.findAllUsers();

}

}

将dwr的js支持库加入页面

检测

运行tomcat,在地址栏输入localhost:8080/dwr 查看是否有你定义的controller,点击进去执行定义的方法execute。查看返回值是否正确(json类型的)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值