add postData to get data
This commit is contained in:
@ -11,7 +11,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
//import javax.servlet.ServletContext;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.xpath.XPath;
|
||||
@ -20,6 +20,7 @@ import javax.xml.xpath.XPathExpression;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@ -39,22 +40,17 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import tctable.Tools;
|
||||
import tools.DBTools;
|
||||
import tools.XMLTools;
|
||||
import tools.User;
|
||||
import tools.xml.XMLTools;
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionAttributes( { "user" }) //Сесионный объект!
|
||||
public class DBMSTree implements ServletContextAware {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DBMSTree.class);
|
||||
private ServletContext context;
|
||||
|
||||
//If not created object "user", create him.
|
||||
@ModelAttribute("user")
|
||||
public User populatePerson() {
|
||||
return new User("none");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/tree",method = RequestMethod.POST,produces = "application/xml; charset=utf-8")
|
||||
@ResponseBody
|
||||
public Object ajaxTamer(@ModelAttribute User user,@RequestBody byte[] reqData,@RequestParam(required=false,name="lng") String language_id) {
|
||||
@ -73,13 +69,13 @@ public class DBMSTree implements ServletContextAware {
|
||||
String db_password="";
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(new FileInputStream("application.properties")); // load a properties file
|
||||
prop.load(new FileInputStream("org_ccalm_main.properties")); // load a properties file
|
||||
db_url = prop.getProperty("spring.datasource.url");
|
||||
db_login = prop.getProperty("spring.datasource.username");
|
||||
db_password = prop.getProperty("spring.datasource.password");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error load application.properties",e);
|
||||
logger.error("Error load org_ccalm_main.properties",e);
|
||||
}
|
||||
|
||||
Connection conn = null;
|
||||
@ -188,7 +184,7 @@ public class DBMSTree implements ServletContextAware {
|
||||
{
|
||||
String vt = nF.getAttributes().getNamedItem("vt").getNodeValue();
|
||||
String val= XMLTools.getCDATAValue(nF);
|
||||
sql = sql.replace("${" + nF.getAttributes().getNamedItem("n").getNodeValue() + "}", Tools.getSQLValue(vt, val));
|
||||
sql = sql.replace("${" + nF.getAttributes().getNamedItem("n").getNodeValue() + "}", DBTools.getSQLValue(vt, val));
|
||||
}
|
||||
nF=nF.getNextSibling();
|
||||
}
|
||||
@ -218,9 +214,9 @@ public class DBMSTree implements ServletContextAware {
|
||||
String iid="";
|
||||
String val="";
|
||||
|
||||
if(Tools.hasColumn(rs,"id")) fid=rs.getString("id"); else fid=""; //Уникальный id записи
|
||||
if(Tools.hasColumn(rs,"icon_id")) iid=rs.getString("icon_id"); else iid=""; //id значка
|
||||
if(Tools.hasColumn(rs,caption)) val=rs.getString(caption); else val=""; //Заголовок
|
||||
if(DBTools.hasColumn(rs,"id")) fid=rs.getString("id"); else fid=""; //Уникальный id записи
|
||||
if(DBTools.hasColumn(rs,"icon_id")) iid=rs.getString("icon_id"); else iid=""; //id значка
|
||||
if(DBTools.hasColumn(rs,caption)) val=rs.getString(caption); else val=""; //Заголовок
|
||||
|
||||
String visible = "";
|
||||
if(tmpNode.getAttributes().getNamedItem("visible").getNodeValue().equals("0")) visible=" visible=\"0\" ";
|
||||
@ -248,7 +244,7 @@ public class DBMSTree implements ServletContextAware {
|
||||
String fval="";
|
||||
try
|
||||
{
|
||||
if(Tools.hasColumn(rs,fname))
|
||||
if(DBTools.hasColumn(rs,fname))
|
||||
{
|
||||
fval=rs.getString(fname);
|
||||
}else
|
||||
@ -432,17 +428,16 @@ public class DBMSTree implements ServletContextAware {
|
||||
{
|
||||
if(nF.getNodeName().equals("column"))
|
||||
{
|
||||
sql = sql.replace("{"+nF.getAttributes().getNamedItem("n").getNodeValue()+"}", Tools.getSQLValue(nF.getAttributes().getNamedItem("vt").getNodeValue(),XMLTools.getCDATAValue(nF)));
|
||||
sql = sql.replace("{"+nF.getAttributes().getNamedItem("n").getNodeValue()+"}", DBTools.getSQLValue(nF.getAttributes().getNamedItem("vt").getNodeValue(),XMLTools.getCDATAValue(nF)));
|
||||
}
|
||||
nF=nF.getNextSibling();
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setServletContext(ServletContext servletContext) {
|
||||
this.context=servletContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user