String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
PreparedStatement pt=null;
Connection con = null;
User user = null;
try {
//JDBC访问数据库
con=DBConnection.openConnection();//获取数据库连接
String sql="SELECT * from login WHERE user=? AND passwod=?";
pt=con.prepareStatement(sql);
pt.setString(1, name);
pt.setString(2, pwd);
ResultSet rs=pt.executeQuery();
System.out.println("?????????????????????");
if(rs.next())
{
response.sendRedirect("connsuccess.jsp");
}
else{
response.sendRedirect("connError.jsp");
}
} catch (SQLException e) {
e.printStackTrace();}
import 'dart:ffi' as ffi;
import 'dart:io' show Platform;
/// 根据C中的函数来定义方法签名(所谓方法签名,就是对一个方法或函数的描述,包括返回值类型,形参类型)
/// 这里需要定义两个方法签名,一个是C语言中的,一个是转换为Dart之后的
typedef NativeAddSign = ffi.Int32 Function(ffi.Int32,ffi.Int32);
typedef DartAddSign = int Function(int, int);
/// showBox函数方法签名
typedef NativeShowSign = ffi.Void Function();
typedef DartShowSign = void Function();
void main(List<String> args) {
if (Platform.isWindows) {
// 加载dll动态库
ffi.DynamicLibrary dl = ffi.DynamicLibrary.open("../src/test.dll");
// lookupFunction有两个作用,1、去动态库中查找指定的函数;2、将Native类型的C函数转化为Dart的Function类型
var add = dl.lookupFunction<NativeAddSign, DartAddSign>("add");
var showBox = dl.lookupFunction<NativeShowSign, DartShowSign>("showBox");
// 调用add函数
print(add(8, 9));
// 调用showBox函数
showBox();
}
}
import 'dart:ffi';
import 'dart:io' show Platform;
import "dart:convert";
/// encrypt函数方法签名,注意,这里encrypt和decrypt的方法签名实际上是一样的,两个函数返回值类型和参数类型完全相同
typedef NativeEncrypt = Void Function(CString,CString,Int32);
typedef DartEncrypt = void Function(CString,CString,int);
void main(List<String> args) {
if (Platform.isWindows) {
// 加载dll动态库
DynamicLibrary dl = DynamicLibrary.open("../src/encrypt_test.dll");
var encrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("encrypt");
var decrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("decrypt");
CString data = CString.allocate("helloworld");
CString enResult = CString.malloc(100);
encrypt(data,enResult,100);
print(CString.fromUtf8(enResult));
print("-------------------------");
CString deResult = CString.malloc(100);
decrypt(enResult,deResult,100);
print(CString.fromUtf8(deResult));
}
}
/// 创建一个类继承Pointer<Int8>指针,用于处理C语言字符串和Dart字符串的映射
class CString extends Pointer<Int8> {
/// 申请内存空间,将Dart字符串转为C语言字符串
factory CString.allocate(String dartStr) {
List<int> units = Utf8Encoder().convert(dartStr);
Pointer<Int8> str = allocate(count: units.length + 1);
for (int i = 0; i < units.length; ++i) {
str.elementAt(i).store(units[i]);
}
str.elementAt(units.length).store(0);
return str.cast();
}
// 申请指定大小的堆内存空间
factory CString.malloc(int size) {
Pointer<Int8> str = allocate(count: size);
return str.cast();
}
/// 将C语言中的字符串转为Dart中的字符串
static String fromUtf8(CString str) {
if (str == null) return null;
int len = 0;
while (str.elementAt(++len).load<int>() != 0);
List<int> units = List(len);
for (int i = 0; i < len; ++i) units[i] = str.elementAt(i).load();
return Utf8Decoder().convert(units);
}
}
import 'dart:ffi';
import 'dart:io' show Platform;
import "dart:convert";
/// encrypt函数方法签名,注意,这里encrypt和decrypt的方法签名实际上是一样的,两个函数返回值类型和参数类型完全相同
typedef NativeEncrypt = Void Function(CString,CString,Int32);
typedef DartEncrypt = void Function(CString,CString,int);
void main(List<String> args) {
if (Platform.isWindows) {
// 加载dll动态库
DynamicLibrary dl = DynamicLibrary.open("../src/hello.dll");
var encrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("encrypt");
var decrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("decrypt");
// 创建Reference 跟踪CString
Reference ref = Reference();
CString data = CString.allocate("helloworld",ref);
CString enResult = CString.malloc(100,ref);
encrypt(data,enResult,100);
print(CString.fromUtf8(enResult));
print("-------------------------");
CString deResult = CString.malloc(100,ref);
decrypt(enResult,deResult,100);
print(CString.fromUtf8(deResult));
// 用完后手动释放
ref.finalize();
}
}
class CString extends Pointer<Int8> {
/// 开辟内存控件,将Dart字符串转为C语言字符串
factory CString.allocate(String dartStr, [Reference ref]) {
List<int> units = Utf8Encoder().convert(dartStr);
Pointer<Int8> str = allocate(count: units.length + 1);
for (int i = 0; i < units.length; ++i) {
str.elementAt(i).store(units[i]);
}
str.elementAt(units.length).store(0);
ref?.ref(str);
return str.cast();
}
factory CString.malloc(int size, [Reference ref]) {
Pointer<Int8> str = allocate(count: size);
ref?.ref(str);
return str.cast();
}
/// 将C语言中的字符串转为Dart中的字符串
static String fromUtf8(CString str) {
if (str == null) return null;
int len = 0;
while (str.elementAt(++len).load<int>() != 0);
List<int> units = List(len);
for (int i = 0; i < len; ++i) units[i] = str.elementAt(i).load();
return Utf8Decoder().convert(units);
}
}
import 'dart:ffi';
import 'dart:io' show Platform;
import "dart:convert";
/// encrypt函数方法签名,注意,这里encrypt和decrypt的方法签名实际上是一样的,两个函数返回值类型和参数类型完全相同
typedef NativeEncrypt = Void Function(CString,CString,Int32);
typedef DartEncrypt = void Function(CString,CString,int);
void main(List<String> args) {
if (Platform.isWindows) {
// 加载dll动态库
DynamicLibrary dl = DynamicLibrary.open("../src/hello.dll");
var encrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("encrypt");
var decrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("decrypt");
// 创建Reference 跟踪CString
Reference ref = Reference();
CString data = CString.allocate("helloworld",ref);
CString enResult = CString.malloc(100,ref);
encrypt(data,enResult,100);
print(CString.fromUtf8(enResult));
print("-------------------------");
CString deResult = CString.malloc(100,ref);
decrypt(enResult,deResult,100);
print(CString.fromUtf8(deResult));
// 用完后手动释放
ref.finalize();
}
}
class CString extends Pointer<Int8> {
/// 开辟内存控件,将Dart字符串转为C语言字符串
factory CString.allocate(String dartStr, [Reference ref]) {
List<int> units = Utf8Encoder().convert(dartStr);
Pointer<Int8> str = allocate(count: units.length + 1);
for (int i = 0; i < units.length; ++i) {
str.elementAt(i).store(units[i]);
}
str.elementAt(units.length).store(0);
ref?.ref(str);
return str.cast();
}
factory CString.malloc(int size, [Reference ref]) {
Pointer<Int8> str = allocate(count: size);
ref?.ref(str);
return str.cast();
}
/// 将C语言中的字符串转为Dart中的字符串
static String fromUtf8(CString str) {
if (str == null) return null;
int len = 0;
while (str.elementAt(++len).load<int>() != 0);
List<int> units = List(len);
for (int i = 0; i < len; ++i) units[i] = str.elementAt(i).load();
return Utf8Decoder().convert(units);
}
}
import 'dart:ffi';
import 'dart:io' show Platform;
import "dart:convert";
/// encrypt函数方法签名,注意,这里encrypt和decrypt的方法签名实际上是一样的,两个函数返回值类型和参数类型完全相同
typedef NativeEncrypt = Void Function(CString,CString,Int32);
typedef DartEncrypt = void Function(CString,CString,int);
void main(List<String> args) {
if (Platform.isWindows) {
// 加载dll动态库
DynamicLibrary dl = DynamicLibrary.open("../src/hello.dll");
var encrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("encrypt");
var decrypt = dl.lookupFunction<NativeEncrypt, DartEncrypt>("decrypt");
// 创建Reference 跟踪CString
Reference ref = Reference();
CString data = CString.allocate("helloworld",ref);
CString enResult = CString.malloc(100,ref);
encrypt(data,enResult,100);
print(CString.fromUtf8(enResult));
print("-------------------------");
CString deResult = CString.malloc(100,ref);
decrypt(enResult,deResult,100);
print(CString.fromUtf8(deResult));
// 用完后手动释放
ref.finalize();
}
}
class CString extends Pointer<Int8> {
/// 开辟内存控件,将Dart字符串转为C语言字符串
factory CString.allocate(String dartStr, [Reference ref]) {
List<int> units = Utf8Encoder().convert(dartStr);
Pointer<Int8> str = allocate(count: units.length + 1);
for (int i = 0; i < units.length; ++i) {
str.elementAt(i).store(units[i]);
}
str.elementAt(units.length).store(0);
ref?.ref(str);
return str.cast();
}
factory CString.malloc(int size, [Reference ref]) {
Pointer<Int8> str = allocate(count: size);
ref?.ref(str);
return str.cast();
}
/// 将C语言中的字符串转为Dart中的字符串
static String fromUtf8(CString str) {
if (str == null) return null;
int len = 0;
while (str.elementAt(++len).load<int>() != 0);
List<int> units = List(len);
for (int i = 0; i < len; ++i) units[i] = str.elementAt(i).load();
return Utf8Decoder().convert(units);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd ">
</beans>
@Controller
@RequestMapping("/test")
public class TestController {
@RequestMapping("/hello.do")
public String hello() {
return "index";
}
@RequestMapping("/reparam.do")
public String reparam(HttpServletRequest req) {
String name=req.getParameter("name");
System.out.println(name);
return "index";
}
/*
* 底层走的就是HttpServletRequest
*/
@RequestMapping("/re2.do")
public String re2(String name) {
System.out.println(name);
return "index";
}
@RequestMapping("/re3.do")
public String re3(String name,Integer id,Date bir) {
System.out.println(name+" "+id+" "+bir);
return "index";
}
@InitBinder
public void initBind(ServletRequestDataBinder binder) {
binder.registerCustomEditor(Date.class, new CustomDateEditor(
new SimpleDateFormat("yyyy-MM-dd"), true));
}
@RequestMapping("/toform.do")
public String toform() {
return "form";
}
@RequestMapping("/form.do")
public String form(String[] favor) {
for(String fa :favor)
System.out.println(fa);
return "index";
}
@RequestMapping("/toperson.do")
public String toperson(Person person) {
System.out.println(person);
return "success";
}
//参数map是往页面写的
@RequestMapping("/getP.do")
public String getP(Map<String, Object> map) {
Person p1=new Person(2, "lisi", "bj", 2, new Date());
map.put("person", p1);
return "returnPage";
}
//最常用的
@RequestMapping("/getM.do")
public String getM(Model model) {
Person p1=new Person(2, "lisi", "bj", 2, new Date());
model.addAttribute("person", p1);
return "returnPage";
}
}# 数据清洗功能没有开发完毕
def data_parse():
pass
# 数据展示功能
def data_show():
# ret为待mock的数据
# return是字典模型
ret = data_parse()
try:
if ret.get('result') == "success":
return "data parse success"
elif ret.get('result') == "fail":
print("data parse failed: {}".format(ret.get('reason')))
return "data parse failed"
else:
return "Unknow Reason"
except:
return "Server Unknow Reason"############### 基础平台提供的功能如下 ###############
def f1():
print('f1')
def f2():
print('f2')
def f3():
print('f3')
def f4():
print('f4')
############### 业务部门A 调用基础平台提供的功能 ###############
f1()
f2()
f3()
f4()
############### 业务部门B 调用基础平台提供的功能 ###############
f1()
f2()
f3()
f4()