我知道这是一个重复的问题。对不起要问。我在spring mvc应用程序中遇到此错误。 这是我的Impl文件
public Map<String, String> employeelist() {
Map<String, String> map = new HashMap<String, String>();
List<Employee> lang1 = namedParameterJdbcTemplate.query("select * from
employee", new EmployeeMapper());
for (int i = 0; i < lang1.size(); i++) {
map.put(lang1.get(i).getLocalename(), lang1.get(i).getName());
}
return map;
}
public static final class EmployeeMapper implements RowMapper<Employee> {
public Employee mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, String> map = new HashMap<String, String>();
Employee employee = new Employee();
employee.setId(rs.getString("id"));
employee.setName(rs.getString("name"));
employee.setSalary(rs.getString("salary"));
employee.setDesignation(rs.getString("designation"));
employee.setLocalename(rs.getString("localename"));
return employee;
}
}
尝试执行此操作时,我收到类似"Caused by: java.sql.SQLException: Column 'localename' not found"
的错误消息。所有其他字段都正常工作。但对于 localename ,只显示错误。这里有什么问题??请帮帮我..
抱歉我的英语不好
这是我的员工类
package com.bct.internal.form.model;
public class Employee {
private String id;
private String name;
private String salary;
private String designation;
private String localename;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSalary() {
return salary;
}
public void setSalary(String salary) {
this.salary = salary;
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
public String getLocalename() {
return localename;
}
public void setLocalename(String localename) {
this.localename = localename;
}
@Override
public String toString() {
return "Employee [ID=" + id + ", NAME=" + name + ", SALARY=" + salary +
", LOCALE_NAME=" + localename + ", DESIGNATION=" + designation + "]";
}
}
答案 0 :(得分:0)
请检查
SELECT * FROM Employee
或
DESC Employee
列名localename
在表中是否存在。另请检查localename
。
答案 1 :(得分:0)
您应该连接到您的数据库并执行(确保使用正确的架构):
webview.evaluateJavascript(
"(function() { return ('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>'); })();",
new ValueCallback<String>() {
@Override
public void onReceiveValue(String html) {
}
});
您需要100%确定列的名称&#39; localename&#39;返回表上的描述完全匹配,它不应该有下划线或连字符。这可能只是你创建的桌子上的拼写错误。
答案 2 :(得分:0)
如果表中没有列名localename
,则添加列localname
,然后在hbm文件中检查列localname
是否已映射(如果使用hibernate)。