请教一个xml转json的问题

xml转json时,一个list节点下面正好只有一个元素怎么办? 不就转成 json对象 了么?

6个回答

给你一个思路 我以前写的
XMLWriter writer = null;// 声明写XML的对象
SAXReader reader = new SAXReader();
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("GBK");// 设置XML文件的编码格式
String filePath = "测试导入.xml";
File file = new File(filePath);
Document dom = reader.read(file);
Element root = dom.getRootElement();
String rootXmlText=root.asXML();
Document dom1 = DocumentHelper.parseText(rootXmlText);
Element root1 = dom1.getRootElement();
Iterator iter = root1.elementIterator("errorResultList");//获取标签元素值
while (iter.hasNext()) {
Element recordEle = (Element) iter.next();
String text=recordEle.asXML();
org.json.JSONObject xmlJSONObj = XML.toJSONObject(text);
JSONObject j=JSON.parseObject(xmlJSONObj.get("errorResultList").toString());

}
你现在主要的问题就是1.拿到errorResultList,并循环errorResult 2.把errorResult转换成json,
我的while循环里面的那几个方法就是转换json的,你看看适不适用你这个业务。多尝试

sinat_36743893
小二上酒、ㅤㅤㅤ <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.8</version> </dependency>
接近 2 年之前 回复

xml文件的格式贴出来下呗

qq_25176763
奥尔良烤翅 贴在下面了
接近 2 年之前 回复
 <response>
    <success>false</success>
    <retryLater>false</retryLater>
    <errorCode>BATCH_OPERATE_ERROR</errorCode>
    <errorMsg>batch operate error , please pay attention to errorResultList</errorMsg>
    <errorResultList>
        <errorResult>
            <objectId>201808061423522459</objectId>
            <errorInfoList>
                <errorInfo>
                    <errorCode>ILLEGAL_PARAMETER_ERROR</errorCode>
                    <errorMsg>addressPair.receiveAddress.provinceName为空</errorMsg>
                </errorInfo>
            </errorInfoList>
        </errorResult>
    </errorResultList>
</response>

errorResult可以多个

依赖com.alibabafastjson1.2.8com.itextpdfitextpdf<!-- 5.4.3 -->5.5.9com.itextpdfitext-pdfa5.5.9com.itextpdfitext-xtra5.4.4com.itextpdf.toolxmlworker5.5.9com.itextpdfitext-asian5.2.0还一个dom4j的依赖 自己找一下

 public QueueParam readXml(String path) {
        QueueParam queueParam = new QueueParam();
        try {
            SAXReader reader = new SAXReader();
            Document doc = reader.read(new File(path));
            Element root = doc.getRootElement();
            List<Element> list = root.elements();
            Element batchIdEle = list.get(0).element("batchId");
            String batchId = batchIdEle.getText();
            String userId = list.get(0).elementText("userId");
            String taskId = list.get(0).elementText("taskId");
            String data = list.get(0).elementText("data");
            queueParam = new QueueParam(taskId, batchId, userId, data);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return queueParam;
    }

 package com.ifly.ibk.pojo;

public class QueueParam {

    private String taskid;
    private String batchid;
    private String userid;
    private String data;

    public QueueParam() {
    }

    public QueueParam(String taskid, String batchid, String userid, String data) {
        this.taskid = taskid;
        this.batchid = batchid;
        this.userid = userid;
        this.data = data;
    }

    public String getTaskid() {
        return taskid;
    }

    public void setTaskid(String taskid) {
        this.taskid = taskid;
    }

    public String getBatchid() {
        return batchid;
    }

    public void setBatchid(String batchid) {
        this.batchid = batchid;
    }

    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"taskid\":\"")
                .append(taskid).append('\"');
        sb.append(",\"batchid\":\"")
                .append(batchid).append('\"');
        sb.append(",\"userid\":\"")
                .append(userid).append('\"');
        sb.append(",\"data\":\"")
                .append(data).append('\"');
        sb.append('}');
        return sb.toString();
    }
}

只有一个和多个是一样的道理啊,你如果要返回list,就把一个对象add到list里面就行了啊

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
请教QT怎么将一个任意类序列化成XML

想要对任意一个类进行序列化成XML,类似于JSON序列化操作一样,读的时候反序列化就可以了,百度查出来C++有一个XmlSerializer可以用,那QT呢?具体要怎么用,最好有相关代码?

ASP POST JSON数据到远程服务端冒号问题

请教各位大神,我使用asp向远程服务器POST数据,json字符串,无法实现: set Httpjson=Server.createobject("MSXML2.ServerXMLHTTP") Httpjson.open "POST",url,False 'Httpjson.setrequestheader "Connection","Keep-Alive" 'Httpjson.setRequestHeader "Content-Type","application/x-www-form-urlencoded" Httpjson.setRequestHeader "Content-Type","application/json" Httpjson.setrequestheader "Content-Length",len(jfsj) Httpjson.send(jfsj) 远程服务器接收到的数据没有JSON 中的冒号;应该这样: details=[{"iId":"01","iName":"111","p":"1","peId":2017,"peName":2017}],但是冒号没有了,而且字符串换行了,ASP中冒号是换行。

请教关于spring mvc中使用json-lib-ext-spring返回json的问题

我做了一个这样的框架: <br />spring+hibernate+spring mvc <br /> <br />想让spring mvc返回json数据,使用了json-lib-ext-spring1.0.2。 <br /> <br />刚弄完时是http://localhost/listPerson.do可以在页面上显示出json数据的,但是后来改了一些东西。然后再调用http://localhost/listPerson.do却不显示json数据了,而是提示下载listPerson.do。请教大家是怎么回事啊? <br /> <br />代码如下: <br /> <br />web.xml <br /><pre name="code" class="java"> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"&gt; &lt;display-name&gt;Spring Annotation MVC Sample&lt;/display-name&gt; &lt;!-- Spring 服务层的配置文件 --&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath:applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- Spring 容器启动监听器 --&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener &lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet&gt; &lt;servlet-name&gt;json&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt; &lt;load-on-startup&gt;2&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;json&lt;/servlet-name&gt; &lt;url-pattern&gt;*.do&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </pre> <br /> <br />applicationContext.xml <br /><pre name="code" class="java"> &lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&gt; &lt;!-- 该 BeanPostProcessor 将自动起作用,对标注 @Autowired 的 Bean 进行自动注入 --&gt; &lt;!-- bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/ --&gt; &lt;!-- &lt;context:annotationconfig/&gt; 将隐式地向 Spring 容器注册 AutowiredAnnotationBeanPostProcessor、 CommonAnnotationBeanPostProcessor、PersistenceAnnotationBeanPostProcessor 以及 equiredAnnotationBeanPostProcessor 这 4 个 BeanPostProcessor。 使用这个选项必须加入最上面的3、6、7项 --&gt; &lt;context:annotation-config/&gt; &lt;!-- &lt;bean id="boss" class="net.sf.test.Boss"/&gt; &lt;bean id="office" class="net.sf.test.Office"&gt; &lt;property name="no" value="001"/&gt; &lt;/bean&gt; &lt;bean id="car" class="net.sf.test.Car" scope="singleton"&gt; &lt;property name="brand" value=" 红旗 CA72"/&gt; &lt;property name="price" value="2000"/&gt; &lt;/bean&gt; --&gt; &lt;aop:config&gt; &lt;aop:advisor pointcut="execution(* net.sf.service.*.*(..))" advice-ref="txAdvice" /&gt; &lt;/aop:config&gt; &lt;tx:advice id="txAdvice"&gt; &lt;tx:attributes&gt; &lt;tx:method name="insert*" /&gt; &lt;tx:method name="update*" /&gt; &lt;tx:method name="*" propagation="REQUIRED"/&gt; &lt;/tx:attributes&gt; &lt;/tx:advice&gt; &lt;!--bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /--&gt; &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt; &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt; &lt;/bean&gt; &lt;bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close"&gt; &lt;property name="driver"&gt;&lt;value&gt;oracle.jdbc.driver.OracleDriver&lt;/value&gt;&lt;/property&gt; &lt;property name="driverUrl"&gt;&lt;value&gt;jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.1)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = orcl)))&lt;/value&gt;&lt;/property&gt; &lt;property name="user" value="test"&gt;&lt;/property&gt; &lt;property name="password" value="test"&gt;&lt;/property&gt; &lt;property name="alias" value="myblogdb"&gt;&lt;/property&gt; &lt;!--property name="houseKeepingSleepTime"&gt;&lt;value&gt;9000&lt;/value&gt;&lt;/property--&gt; &lt;property name="prototypeCount" value="5"&gt;&lt;/property&gt; &lt;property name="maximumConnectionCount" value="100"&gt;&lt;/property&gt; &lt;property name="minimumConnectionCount" value="10"&gt;&lt;/property&gt; &lt;property name="trace" value="true"&gt;&lt;/property&gt; &lt;property name="verbose" value="true"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="database" value="ORACLE" /&gt; &lt;property name="generateDdl" value="true" /&gt; &lt;property name="showSql" value="true" /&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; &lt;context:component-scan base-package="net.sf"&gt; &lt;!--context:include-filter type="aspectj" expression="edu.jlu.fuliang.util..*"/--&gt; &lt;context:include-filter type="regex" expression="net\.sf\.service\..*"/&gt; &lt;context:include-filter type="regex" expression="net\.sf\.test\..*"/&gt; &lt;context:exclude-filter type="regex" expression="net\.sf\.action\..*"/&gt; &lt;/context:component-scan&gt; &lt;/beans&gt; </pre> <br /> <br />json-servlet.xml <br /><pre name="code" class="java"> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"&gt; &lt;!-- ①:对web包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能--&gt; &lt;context:component-scan base-package="net.sf.action"/&gt; &lt;!-- ②:启动Spring MVC的注解功能,完成请求和注解POJO的映射 --&gt; &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/&gt; &lt;!-- ③:对模型视图名称的解析,即在模型视图名称添加前后缀 --&gt; &lt;bean class="org.springframework.web.servlet.view.ResourceBundleViewResolver"/&gt; &lt;/beans&gt; </pre> <br /> <br />views.properties <br /><pre name="code" class="java"> jsonView.(class)=net.sf.json.spring.web.servlet.view.JsonView jsonView.contentType=application/json;charset=UTF-8 </pre> <br /> <br />PersonAction.java <br /><pre name="code" class="java"> package net.sf.action; import net.sf.service.PersonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class PersonAction { @Autowired private PersonService _personService; @RequestMapping("/listPerson.do") // &lt;—— ① public String listPerson(Model m) { //_personService.getList(); m.addAttribute("personList", _personService.getList()); System.out.println("call listAllBoard method.ss"); return "jsonView"; } } </pre> <br /> <br />PersonServiceImpl.java <br /><pre name="code" class="java"> package net.sf.service.impl; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import net.sf.service.PersonService; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; @Scope("prototype") @Service("personService") public class PersonServiceImpl implements PersonService { EntityManager em; @PersistenceContext public void setEm(EntityManager em) { this.em = em; } public List getList(){ String sHql = "FROM Person"; Query query = em.createQuery(sHql); List resultList = query.getResultList(); return resultList; } public String test(){ return "hello world, 雪狐!"; } } </pre>

SSH2整合问题,异步请求到的json无法正常显示中文与英文,均显示??

web.xml <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> struts.properties struts.i18n.encoding =UTF-8 struts.locale=zh_CN struts.objectFactory=spring struts.devMode=true struts.configuration.xml.reload=true struts.serve.static.browserCache=false action ....... response.setContentType("text/html;charset=UTF-8"); List<PageBean> pageBean=newsService.finByPage(currPage); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); JSONArray json = JSONArray.fromObject(pageBean, jsonConfig); System.out.println(json.toString()); out.print(json); out.flush(); out.close(); ....... 页面显示是下面这样的 编号 标题 内容 1 ??? 1546 1 ??? ?? 1 ??? ?? ` 控制台打印出的json是这样的 Array[3]0: Object content:"1546" currPage:1 pageSize:3 title:"???" totalCount:16 totalPage:5 __proto__: Object1: Object2: 我编码都设置为了UTF-8,服务器端的控制台打印出的数据是正常的,但到了页面就成了这样了,中文英文都一律问号,请教各位大哥大姐这该怎么解决,感激不尽 ```

向前辈们请教一下学习经验,自学的我如何拿到4K月薪?

[color=darkblue] [size=large]各位过来人给提提建议吧,我自学JAVA也有3个多月了,做了个图书销售管理系统JSP+Servlet+Jquery+Mysql ,目前自己SSH的话也都学完了,打算这个月用SSH写个OA系统。 我只有这一个月时间了。到了9月底必须去找工作,不然就要饿死了,纠结啊。 因为我想更好的利用这一个月,有效率的锻炼自己所学的知识。[/size] [size=small] 先说明下,我目前熟练掌握的有: jsp el,servlet,filter.(JSTL只是了解,没有怎么用) SSH(注:只会基本的操作,没做过实际项目) 数据库熟悉Oracle和mysql 前台的话 : CSS,HTML,Javascript,Jquery 基本的用法(注:不是特别熟练,jquery还好一点) xml,json这些做过级联[/size] [size=large]我看好多刚入行的待遇大不相同,有2K也有4K,或者更多的。 我想知道他们的差别在哪里? 或者说他们比那些薪水低一点的,多了哪些知识。 我很担心这一个月学了那些跟提高薪水无关紧要的。 请教各位当前要尽快掌握什么才能提高薪水吧,在这个深圳这高消费的城市底薪的话很难活。 [/size][/color]

jQuery 与 .NET 向高手请教

想向各位高手请教一下。 <br /> <br />最近正在学习jQuery,开发语言一直都是.NET,想把jQuery和.NET结合起来学习。 <br />但是在网上查了查,.NET主要是VS2008对jQuery支持,那VS2003和VS2005应该也能支持.NET吧。 <br />只是VS2003没有AJAX,应该对jQuery有所限制,VS2005能安装AJAX,但是VS2005上安装的AJAX感觉很晕,而且没有MVC,所以很不爽。 <br />只有VS2008了,最近刚安装上VS2008,AJAX、MVC倒是都集成了。只是这VS本身也有很多对AJAX的方法,如果也用jQuery,感觉乱乱的。 <br /> <br />还是用PHP和jQuery来的省事儿。 <br /> <br />所以,各们高手大牛们,.NET和jQuery结合用的有多少啊,用着爽不? <br /> <br />还有,PHP和jQuery结合使用的,前后台之间不管什么数据,都是用XML或JSON来传递吗?<br /><strong>问题补充:</strong><br />那VS2003和VS2005应该也能支持.NET吧。 <br />应该是 <br />那VS2003和VS2005应该也能支持jQuery吧。

请教: nginx + tomcat https配置问题

项目需要配置https,根据网上查找资料,进行了以下配置: 1.nginx完整配置文件 ``` #user nobody; worker_processes 4; error_log logs/error.log info; events { worker_connections 65535; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 6m; server { listen 443 ssl; server_name www.xxxx.com; ssl_certificate cert/200000000000006.pem; ssl_certificate_key cert/200000000000006.key; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_prefer_server_ciphers on; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_connect_timeout 3; proxy_send_timeout 300; proxy_read_timeout 300; proxy_pass http://111.111.111.111:1111; } } server { listen 80; server_name xxxx.com; server_name *.xxxx.com; location / { rewrite ^(.*) https://www.xxxx.com permanent; } } } ``` 2.tomcat配置文件 ``` <?xml version='1.0' encoding='utf-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <Listener className="org.apache.catalina.core.JasperListener" /> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <GlobalNamingResources> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <Service name="Catalina"> <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="1000" maxIdleTime="60000" minSpareThreads="20"/> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Connector executor="tomcatThreadPool" port="1111" protocol="org.apache.coyote.http11.Http11AprProtocol" maxHttpHeaderSize="8192" maxThreads="1000" processorCache="1000" acceptCount="1000" minSpareThreads="100" acceptorThreadCount="8" URIEncoding="UTF-8" enableLookups="false" redirectPort="443" proxyPort="443" connectionTimeout="120000" keepAliveTimeout="120000" maxKeepAliveRequests="65535" disableUploadTimeout="true" compression="on" compressionMinSize="4096" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/x-javascript"/> <Engine name="xxxx" defaultHost="www.xxxx.com"> <Host name="www.xxxx.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" remoteIpProxiesHeader="x-forwarded-by" protocolHeader="X-Forwarded-Proto"/> <Context docBase="/usr/local/apache-tomcat-7.0.63/xxxx" path="" reloadable="true" /> </Host> </Engine> </Service> </Server> ``` 启动 nginx 和tomcat后,无法访问。一直连接超时。 麻烦大神帮忙看下,配置哪里有问题,谢谢。

SpringMVC 的 @RequestParam required 失效的问题,请教各位。

<div class="iteye-blog-content-contain" style="font-size: 14px;"> <p>controller部分代码如下:</p> <pre name="code" class="java"> @RequestMapping(value = "/u/info/infoMonitorFromFriend" ) public String infoMonitorFromFriend( @RequestParam(required=false,defaultValue="",value="attid") int[] attid, //信息的属性额 1 原创 2 转发 7回复 @RequestParam(required=false,defaultValue="",value="keyid") int[] keyid, //关键词id 过滤 @RequestParam(required=false,defaultValue="",value="stat") int[] stat, // 状态 @RequestParam(required=false,defaultValue="",value="contentkey") String contentkey, // 内容包涵的词 @RequestParam(required=false,defaultValue="",value="userkey") String userkey, // 用户名包涵的内容 @RequestParam(value="page",defaultValue="1") Integer page, @RequestParam(value="pageSize",defaultValue="5") Integer pageSize, HttpServletRequest request, HttpServletResponse response, ModelMap model ) throws IOException {</pre> <p> </p> <p>当在Spring配置文件中用</p> <pre name="code" class="xml">&lt;mvc:annotation-driven /&gt;</pre> <p> **/u/info/infoMonitorFromFriend?page=1&amp;pageSize=5 这样的URL可以放到controller。</p> <p>但是当我用,</p> <p>org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping</p> <p>org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter</p> <p>来配置,如下</p> <pre name="code" class="xml">&lt;bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"&gt; &lt;property name="order" value="0" /&gt; &lt;/bean&gt; &lt;bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"&gt; &lt;property name="messageConverters"&gt; &lt;list&gt; &lt;bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /&gt; &lt;bean class="org.springframework.http.converter.StringHttpMessageConverter" /&gt; &lt;bean class="org.springframework.http.converter.ResourceHttpMessageConverter" /&gt; &lt;bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" /&gt; &lt;bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" /&gt; &lt;bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" /&gt; &lt;bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" &gt; &lt;property name="supportedMediaTypes"&gt; &lt;list&gt; &lt;value&gt;text/html;charset=UTF-8&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </pre> <p> </p> <p> **/u/info/infoMonitorFromFriend?page=1&amp;pageSize=5 这样的URL就会返回404.</p> <p> </p> <p>求解答~~~~~~~~~~~~~~~~~~~~~~~~~~~~`</p> </div>

微信开发者接口应该如何使用?

请问,微信公众开发平台的开发者文档接口,应该如何使用,能否请教JAVA开发的高手编写一段程序示范一下啊?谢谢。我看到网上有高手用JSON数据写了一段JAVA文件,不知道,是不是还需要配置web.xml等配置文件才能使用啊? http://www.oschina.net/code/snippet_146430_21868 具体就是这位高手写的,能直接导入到ECLIPSE搭建的环境,映射到外网的80端口,做微信的后台吗?

有人用过ajaxfileupload上传图片,然后用Jcrop去截图的么?有个问题请教下!

我用AjaxFileUpload把图片传上去了,然后返回图片的上传路径到前台<img>标签里,为什么返回的高度宽度都是0,然后自动生成的<div>下面的<img>标签也没有获取到src属性 ``` /** * 文件上传 * @param file * @param request * @param response * @return */ @RequestMapping(value = "/uploadFile.do") public @ResponseBody Map<String,Object> uploadFile(@RequestParam(value = "apkFile") MultipartFile file,HttpServletRequest request, HttpServletResponse response) { Map<String,Object> resMap = new HashMap<String,Object>(); //String classPath = this.getClass().getClassLoader().getResource("/").getPath(); String classPath = request.getRealPath("/"); if (file != null) { if (file.isEmpty()) { // 未选择文件 resMap.put("status", "未选择文件"); } else{ // 文件原名称 String originFileName = file.getOriginalFilename(); try { //这里使用Apache的FileUtils方法来进行保存 FileUtils.copyInputStreamToFile(file.getInputStream(), new File(classPath+uploadDir, originFileName)); resMap.put("status","ok"); resMap.put("imgUrl","../"+uploadDir+originFileName); } catch (IOException e) { resMap.put("status", "文件上传失败!"); e.printStackTrace(); } } } return resMap; } ``` 这是我的controller方法 ``` <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link rel="stylesheet" href="../resources/css/jquery.Jcrop.min.css" type="text/css" /> <!-- <script src="../resources/js/common/jquery-1.11.3.js" type="text/javascript"></script> --> <script src="http://edge1u.tapmodo.com/global/js/jquery.min.js"></script> <script src="../resources/js/common/ajaxfileupload.js" type="text/javascript"></script> <script src="../resources/js/fileupload.js" type="text/javascript"></script> <script src="../resources/js/common/jquery.Jcrop.js"></script> <title>上传头像</title> </head> <body> 当前用户: ${userName} <input id="userId" value="${userId }" type="hidden" /> <div id="addApkWindows"> <div id="result"></div> 上传文件: <input type="file" id="apkFile" name="apkFile" /> <input type="button" value="上传" onclick="ajaxFileUpload()" /> </div> <form id="form_save" action="/user/save_portrait" style="display: none;"> <input type="hidden" id="img_left" name="left" value="0"> <input type="hidden" id="img_top" name="top" value="0"> <input type="hidden" id="img_width" name="width" value="0"> <input type="hidden" id="img_height" name="height" value="0"> <input type="hidden" id="img_rd" name="rd" value="0"> </form> <img src="" id="target" /> </body> </html> ``` 这是页面代码 ``` $(function() { $('#target').Jcrop(); }); function ajaxFileUpload() { //获取软件更新详情 var apkIntroduce = $("#apkInfo").val(); //开始上传文件时显示一个图片,文件上传完成将图片隐藏 //$("#loading").ajaxStart(function(){$(this).show();}).ajaxComplete(function(){$(this).hide();}); //执行上传文件操作的函数,使用encodeURI方法,防止传输中文字符的时候出现乱码 var uploadUrl = encodeURI(encodeURI("uploadFile.do?apkIntroduce=" + apkIntroduce)); $.ajaxFileUpload({ //处理文件上传操作的服务器端地址(可以传参数,已亲测可用) url : uploadUrl, // url:basePath + "uploadApk.do?apkIntroduce="+apkIntroduce, secureuri : false, //是否启用安全提交,默认为false fileElementId : 'apkFile', //文件选择框的id属性 dataType : 'text', //服务器返回的格式,可以是json或xml等 success : function(data, status) { //服务器响应成功时的处理函数 var dataset = $.parseJSON(data); if (dataset.status == "ok") { $('#result').html("Apk上传成功"); $('#target').attr("src", dataset.imgUrl); } else if (dataset.status == "parm_is_empty") { $('#result').html("没有选择APK!"); } else { $('#result').html('Apk上传失败,请重试!!'); } }, error : function(data, status, e) { //服务器响应失败时的处理函数 console.log(e); console.log(data); $('#result').html('APK上传失败,请重试!!'); } }); $('#target').Jcrop(); } ``` ![](http://static.oschina.net/uploads/space/2015/1115/231553_hcvJ_2392241.png) 这是上传后的页面效果图

springmvc页面无法跳转问题

请教大神一下,我用springmvc想在A页面提交数据然后带到B页面,什么报错都没有,在控制台里还能看到这个请求的相应就是B页面,但是页面不跳过去是为什么?哪位大神能帮我看下。 ![图片说明](https://img-ask.csdn.net/upload/201608/16/1471315138_907044.png) web.xml的配置 <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring/spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.htm</url-pattern> <url-pattern>*.json</url-pattern> <url-pattern>*.do</url-pattern> </servlet-mapping> spring-mvc.xml的配置 <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="ignoreAcceptHeader" value="true"/> <property name="defaultContentType" value="text/html"/> <property name="mediaTypes"> <map> <entry key="json" value="application/json"/> <entry key="htm" value="text/html"/> </map> </property> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/"/> <property name="suffix" value=".jsp"/> </bean> </list> </property> </bean> controller的代码: @RequestMapping("/nextToSaveRpinfo") public String toSaveRpinfo(Rpinfo rpinfo, HttpServletRequest request, HttpServletResponse response, ModelMap model){ try { String address2 = rpinfo.getAddress(); System.out.println(address2); String source = request.getParameter("source"); model.addAttribute("source",source); model.addAttribute("rpinfo", rpinfo); } catch (Exception e) { e.printStackTrace(); logger.error("发生异常:"+e.getMessage()); } System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1"); //这里控制台有打印 return "page/appeal"; }

php如何上传图片到第三方API取返回地址

网上有找到一个源码,但是太花俏了,用的全是JS,我完全看不懂。 所以在这请教大哥们能帮我写个简单的,只需要提交上传取返回地址。 我菜鸟,太复杂看不懂! https://sm.ms/api/upload 这是post API接口 这是提交参数描述 ``` 参数名称 类型 是否必须 描述 smfile File 是 表单名称。上传图片用到 ssl Bool 否 是否使用 https 输出,强制开启 format String 否 输出的格式。可选值有 json、xml。默认为 json ``` 这是返回值 ``` 名称 类型 示例值 描述 code String success 上传文件状态。正常情况为 success。出现错误时为 error filename String smms.jpg 上传文件时所用的文件名 storename String 561cc4e3631b1.png 上传后的文件名 size Int 187851 文件大小 width Int 1157 图片的宽度 height Int 680 图片的高度 hash String nLbCw63NheaiJp1 随机字符串,用于删除文件 delete String https://sm.ms/api/delete/nLbCw63NheaiJp1 删除上传的图片文件专有链接 url String https://ooo.0o0.ooo/2015/10/13/561cfc3282a13.png 图片服务器地址 path String /2015/10/13/561cfc3282a13.png 图片的相对地址 msg String No files were uploaded. 上传图片出错时将会出现 ``` 问题已解决!!!!!!!!!!!!!! ![图片说明](https://img-ask.csdn.net/upload/201806/13/1528866247_344411.jpg)

用ajax访问struts2一个action不成功,望赐教

[size=medium][/size] 初用jquery,运行一个小例子不成功,按了按钮,应该进入不到 $(document).ready(function) 里面,不然alert(“Hello”)也不会没反应吧。贴上代码,望赐教。 再请教一个语法问题,能否在 $(document).ready(function(){ $("#login").click(function(){ if(true){ // 这样用if语句应该是允许的? alert("hello"); } }); }); applicationContext里面的Action定义 [code="xml"] <!--************************ 响应AJAX的actions ************************--> <bean name="noticeAction" class="com.demo.struts2.actions.NoticeAction"> <property name="noticeDAO"> <ref local="noticeDAO" /> </property> </bean> [/code] struts.xml里面的代码 [code="xml"] <package name="login" namespace="/" extends="json-default"> <action name="login" class="noticeAction" method="login"> <!-- 返回类型为json 在sjon-default中定义 --> <result type="json"> <!-- root的值对应要返回的值的属性 --> <!-- 这里的result值即是 对应action中的 result --> <param name="root">result</param> </result> </action> </package> [/code] test.jsp的代码 [code="jsp"] <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function(){ $("#login").click(function(){ alert("hello"); login(); }); }); function login(){ var url="login.action"; var params={"user.logName":$("#name").attr("value"),"user.password":$("#password").attr("value")}; &.getJSON(url,params,function callback(data){ //convert to json object var user=eval("("+data+")");// $("#result").each(function(){ $(this).html('welcome ,'+user.name); }); }); } </script> </head> <body> <s:actionmessage /> <form method="post" id="form"> <s:text name="用户名:" /> : <input type="textbox" name="user.logName" id="name" value='${param["user.logName"]} ' /> <br> <s:text name="密码:" /> : <input type="password" id="password" name="user.password" /> <br> <input type="button" id="login" value='<s:text name="登陆"/>' /> </form> <div id="result"> </div> </body> </html> [/code] 对应的action [code="java"] [/code]

restful请求index方法时,真正请求的是index_get的方法,请教下源代码这块逻辑在哪。

请求的域名是:cidemo.com/Admin/RestfulController/index/2 但是走的是 Admin模块下的RestfulController控制器中的index_get 得方法 RestfulController控制器中我继承了REST_Controller 但是在REST_Controller 中我没发现将index 变成 index_get的逻辑啊。有哪位大神帮忙解答下 处理逻辑的控制器文件: ``` <?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * Example * * This is an example of a few basic user interaction methods you could use * all done with a hardcoded array. * */ // This can be removed if you use __autoload() in config.php OR use Modular Extensions require APPPATH . '/libraries/REST_Controller.php'; class Restful extends REST_Controller { function index_get($id = '') { var_dump($id);die; // Example data for testing. $widgets = array( 1 => array('id' => 1, 'name' => 'sprocket'), 2 => array('id' => 2, 'name' => 'gear') ); if (!$id) { $id = $this->get('id'); } if (!$id) { //$widgets = $this->widgets_model->getWidgets(); if ($widgets) $this->response($widgets, 200); // 200 being the HTTP response code else $this->response(array('error' => 'Couldn\'t find any widgets!'), 404); } //$widget = $this->widgets_model->getWidget($id); $widget = @$widgets[$id]; // test code if ($widget) $this->response($widget, 200); // 200 being the HTTP response code else $this->response(array('error' => 'Widget could not be found'), 404); } function index_post() { $data = $this->_post_args; try { //$id = $this->widgets_model->createWidget($data); $id = 3; // test code //throw new Exception('Invalid request data', 400); // test code //throw new Exception('Widget already exists', 409); // test code } catch (Exception $e) { // Here the model can throw exceptions like the following: // * For invalid input data: new Exception('Invalid request data', 400) // * For a conflict when attempting to create, like a resubmit: new Exception('Widget already exists', 409) $this->response(array('error' => $e->getMessage()), $e->getCode()); } if ($id) { $widget = array('id' => $id, 'name' => $data['name']); // test code //$widget = $this->widgets_model->getWidget($id); $this->response($widget, 201); // 201 being the HTTP response code } else $this->response(array('error' => 'Widget could not be created'), 404); } public function index_put() { $data = $this->_put_args; try { //$id = $this->widgets_model->updateWidget($data); $id = $data['id']; // test code //throw new Exception('Invalid request data', 400); // test code } catch (Exception $e) { // Here the model can throw exceptions like the following: // * For invalid input data: new Exception('Invalid request data', 400) // * For a conflict when attempting to create, like a resubmit: new Exception('Widget already exists', 409) $this->response(array('error' => $e->getMessage()), $e->getCode()); } if ($id) { $widget = array('id' => $data['id'], 'name' => $data['name']); // test code //$widget = $this->widgets_model->getWidget($id); $this->response($widget, 200); // 200 being the HTTP response code } else $this->response(array('error' => 'Widget could not be found'), 404); } function index_delete($id = '') { // Example data for testing. $widgets = array( 1 => array('id' => 1, 'name' => 'sprocket'), 2 => array('id' => 2, 'name' => 'gear'), 3 => array('id' => 3, 'name' => 'nut') ); if (!$id) { $id = $this->get('id'); } if (!$id) { $this->response(array('error' => 'An ID must be supplied to delete a widget'), 400); } //$widget = $this->widgets_model->getWidget($id); $widget = @$widgets[$id]; // test code if ($widget) { try { //$this->widgets_model->deleteWidget($id); //throw new Exception('Forbidden', 403); // test code } catch (Exception $e) { // Here the model can throw exceptions like the following: // * Client is not authorized: new Exception('Forbidden', 403) $this->response(array('error' => $e->getMessage()), $e->getCode()); } $this->response($widget, 200); // 200 being the HTTP response code } else $this->response(array('error' => 'Widget could not be found'), 404); } public function response($info) { if (is_array($info)) { echo json_encode($info); } } public function index(){ echo "this is index methods"; } } ``` 继承的restful类文件: ``` <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class REST_Controller extends CI_Controller { private $method; private $format; private $get_args; private $put_args; private $args; // List all supported methods, the first will be the default format private $supported_formats = array( 'xml' => 'application/xml', 'json' => 'application/json', 'serialize' => 'text/plain', 'php' => 'text/plain', 'html' => 'text/html', 'csv' => 'application/csv' ); // Constructor function function __construct() { parent::__construct(); // How is this request being made? POST, DELETE, GET, PUT? $this->method = $this->_detect_method(); // Lets grab the config and get ready to party $this->load->config('rest'); if($this->config->item('rest_auth') == 'basic') { echo "basic"; $this->_prepareBasicAuth(); } elseif($this->config->item('rest_auth') == 'digest') { echo "digest"; $this->_prepareDigestAuth(); } // Set up our GET variables $this->get_args = $this->uri->uri_to_assoc();//获取参数 var_dump($this->get_args); // Set up out PUT variables var_dump(parse_str(file_get_contents('php://input'), $this->put_args)); parse_str(file_get_contents('php://input'), $this->put_args); // Merge both for one mega-args variable $this->args = array_merge($this->get_args, $this->put_args); // Which format should the data be returned in? $this->format = $this->_detect_format();//设置参数方式 json 、 xml } /* * Remap * * Requests are not made to methods directly The request will be for an "object". * this simply maps the object and method to the correct Controller method. */ function _remap($object_called) { $controller_method = $object_called.'_'.$this->method; if(method_exists($this, $controller_method)) { $this->$controller_method(); } else { show_404(); } } /* * Responce * * Takes pure data and optionally a status code, then creates the responce */ function responce($data = '', $http_code = 200) { $this->output->set_status_header($http_code); // If the method exists, call it if(method_exists($this, '_'.$this->format)) { // Set a XML header $this->output->set_header('Content-type: '.$this->supported_formats[$this->format]); $formatted_data = $this->{'_'.$this->format}($data); $this->output->set_output( $formatted_data ); } else { $this->output->set_output( $data ); } } /* * Detect format * * Detect which format should be used to output the data */ private function _detect_format() { if(array_key_exists('format', $this->args) && array_key_exists($this->args['format'], $this->supported_formats)) { return $this->args['format']; } // If a HTTP_ACCEPT header is present... if($this->input->server('HTTP_ACCEPT')) { // Check to see if it matches a supported format foreach(array_keys($this->supported_formats) as $format) { if(strpos($this->input->server('HTTP_ACCEPT'), $format) !== FALSE) { return $format; } } } // If it doesnt match any or no HTTP_ACCEPT header exists, uses the first (default) supported format list($default)=array_keys($this->supported_formats); return $default; } /* * Detect method * * Detect which method (POST, PUT, GET, DELETE) is being used */ private function _detect_method() { $method = strtolower($this->input->server('REQUEST_METHOD')); if(in_array($method, array('get', 'delete', 'post', 'put'))) { return $method; } return 'get'; } // INPUT FUNCTION -------------------------------------------------------------- public function get($key) { return array_key_exists($key, $this->get_args) ? $this->input->xss_clean( $this->get_args[$key] ) : $this->input->get($key) ; } public function post($key) { return $this->input->post($key); } public function put($key) { return array_key_exists($key, $this->put_args) ? $this->input->xss_clean( $this->put_args[$key] ) : FALSE ; } // SECURITY FUNCTIONS --------------------------------------------------------- private function _checkLogin($username = '', $password = NULL) { if(empty($username)) { return FALSE; } $valid_logins =& $this->config->item('rest_valid_logins'); if(!array_key_exists($username, $valid_logins)) { return FALSE; } // If actually NULL (not empty string) then do not check it if($password !== NULL) { if($valid_logins[$username] != $password) { return FALSE; } } return TRUE; } private function _prepareBasicAuth() { $username = NULL; $password = NULL; // mod_php if (isset($_SERVER['PHP_AUTH_USER'])) { $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; } // most other servers elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) { if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']),'basic')===0) { list($username,$password) = explode(':',base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); } } if ( !$this->_checkLogin($username, $password) ) { $this->_forceLogin(); } } private function _prepareDigestAuth() { $uniqid = uniqid(""); // Empty argument for backward compatibility // We need to test which server authentication variable to use // because the PHP ISAPI module in IIS acts different from CGI if(isset($_SERVER['PHP_AUTH_DIGEST'])) { $digest_string = $_SERVER['PHP_AUTH_DIGEST']; } elseif(isset($_SERVER['HTTP_AUTHORIZATION'])) { $digest_string = $_SERVER['HTTP_AUTHORIZATION']; } else { $digest_string = ""; } /* The $_SESSION['error_prompted'] variabile is used to ask the password again if none given or if the user enters a wrong auth. informations. */ if ( empty($digest_string) ) { $this->_forceLogin($uniqid); exit; } // We need to retrieve authentication informations from the $auth_data variable preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches); $digest = array_combine($matches[1], $matches[2]); if ( !array_key_exists('username', $digest) || !$this->_checkLogin($digest['username']) ) { $this->responce(NULL, 401); exit; } $valid_logins =& $this->config->item('rest_valid_logins'); $valid_pass = $valid_logins[$digest['username']]; // This is the valid response expected $A1 = md5($digest['username'] . ':' . $this->config->item('rest_realm') . ':' . $valid_pass); $A2 = md5(strtoupper($this->method).':'.$digest['uri']); $valid_response = md5($A1.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$A2); if ($digest['response'] != $valid_response) { $this->responce(NULL, 401); exit; } } private function _forceLogin($nonce = '') { header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.1 401 Unauthorized'); if($this->config->item('rest_auth') == 'basic') { header('WWW-Authenticate: Basic realm="'.$this->config->item('rest_realm').'"'); } elseif($this->config->item('rest_auth') == 'digest') { header('WWW-Authenticate: Digest realm="'.$this->config->item('rest_realm'). '" qop="auth" nonce="'.$nonce.'" opaque="'.md5($this->config->item('rest_realm')).'"'); } echo 'Text to send if user hits Cancel button'; die(); } // FORMATING FUNCTIONS --------------------------------------------------------- // Format XML for output private function _xml($data = array(), $structure = NULL, $basenode = 'xml') { // turn off compatibility mode as simple xml throws a wobbly if you don't. if (ini_get('zend.ze1_compatibility_mode') == 1) { ini_set ('zend.ze1_compatibility_mode', 0); } if ($structure == NULL) { $structure = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$basenode />"); } // loop through the data passed in. foreach($data as $key => $value) { // no numeric keys in our xml please! if (is_numeric($key)) { // make string key... //$key = "item_". (string) $key; $key = "item"; } // replace anything not alpha numeric $key = preg_replace('/[^a-z0-9_-]/i', '', $key); // if there is another array found recrusively call this function if (is_array($value)) { $node = $structure->addChild($key); // recrusive call. $this->_xml($value, $node, $basenode); } else { // add single node. $value = htmlentities($value, ENT_NOQUOTES, "UTF-8"); $UsedKeys[] = $key; $structure->addChild($key, $value); } } // pass back as string. or simple xml object if you want! return $structure->asXML(); } // Format HTML for output private function _html($data = array()) { // Multi-dimentional array if(isset($data[0])) { $headings = array_keys($data[0]); } // Single array else { $headings = array_keys($data); } $this->load->library('table'); $this->table->set_heading($headings); foreach($data as &$row) { $this->table->add_row($row); } return $this->table->generate(); } // Format HTML for output private function _csv($data = array()) { // Multi-dimentional array if(isset($data[0])) { $headings = array_keys($data[0]); $output = implode(',', $headings)."\r\n"; foreach($data as &$row) { $output .= '"'.implode('","',$row)."\"\r\n"; } } // Single array else { $headings = array_keys($data); $output = implode(',', $headings)."\r\n"; $output .= '"'.implode('","',$data)."\"\r\n"; } return $output; } // Encode as JSON private function _json($data = array()) { return json_encode($data); } // Encode as Serialized array private function _serialize($data = array()) { return serialize($data); } // Encode raw PHP private function _php($data = array()) { return var_export($data); } } ?> ```

请教:查询数据库里面数据报错,报错信息如下:

org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY b.GL_ID DESC) as rownumber from (select u.USER_ID, u.USERNAME, ' at line 1 ### The error may exist in file [E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\FHMYSQL\WEB-INF\classes\mybatis\system\UserXMapper.xml] ### The error may involve UserXMapper.userlistPage-Inline ### The error occurred while setting parameters ### SQL: select * from (select tmp_tb.*, row_number() over(ORDER BY b.GL_ID DESC) as rownumber from (select u.USER_ID, u.USERNAME, u.PASSWORD, u.LAST_LOGIN, u.NAME, u.IP, u.EMAIL, u.NUMBER, u.PHONE, r.ROLE_ID, r.ROLE_NAME from SYS_USER u, SYS_ROLE r where u.ROLE_ID = r.ROLE_ID and u.USERNAME != 'admin' and (r.ROLE_ID != '7' and r.PARENT_ID != '7') order by u.LAST_LOGIN desc) as tmp_tb ) as t1 where rownumber between 0 and 10 ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY b.GL_ID DESC) as rownumber from (select u.USER_ID, u.USERNAME, ' at line 1 ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY b.GL_ID DESC) as rownumber from (select u.USER_ID, u.USERNAME, ' at line 1 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364) at com.sun.proxy.$Proxy12.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194) at com.fh.dao.DaoSupport.findForList(DaoSupport.java:118) at com.fh.service.system.user.UserService.listPdPageUser(UserService.java:84) at com.fh.service.system.user.UserService$$FastClassBySpringCGLIB$$9ae06eae.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644) at com.fh.service.system.user.UserService$$EnhancerBySpringCGLIB$$fd8ca82d.listPdPageUser(<generated>) at com.fh.controller.system.user.UserController.listUsers(UserController.java:254) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)

Android使用volley进行post请求时 response code 400 for 问题

用xUtils请求就没有问题,之前用volley发送post请求时服务器返回的错误是参数为null,今天直接volley报Unexpected response code 400 for ...的serverError,诚心请教各位大神。。

nginx重复发送请求到服务器

在测试环境进行nginx配置时,为防止超时,全部把超时参数配置为10分钟。但是在拉取数据时还是到60S后就报错,提示“数据正在下载中,请稍后再试“,表明已在缓存中。 目前怀疑是nginx重复发送请求(或者请求超时之后,nginx把请求转发给另一台服务器)所致,因为跳过nginx服务器拉取数据是正常的。 配置如下: http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log log/main-access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 600; lingering_timeout 600; send_timeout 600; gzip on; gzip_min_length 1k; gzip_buffers 8 32k; gzip_comp_level 6; gzip_types text/html text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; client_max_body_size 8m; client_body_buffer_size 256k; client_header_timeout 600; client_body_timeout 600; proxy_next_upstream off; proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; proxy_buffer_size 128k; proxy_buffers 8 256k; proxy_busy_buffers_size 256k; proxy_temp_file_write_size 256k; upstream web1 { server ip:port; } upstream web2 { server ip:port; } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://web1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; index index.html index.jsp login.jsp index.htm; #root html; #index index.html index.htm; } location /admin { proxy_pass http://web2; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; index index.html index.jsp login.jsp index.htm; } ... } ... } 请教一下,如果避免nginx重复请求,该怎么设置? 或者nginx转发请求给另一台服务器,又该怎么设置? 如果问题不是出在这里,那么该怎么分析并解决这个问题? nginx接触不久,很多配置还都不熟悉,恳请对nginx了解的大神能不吝指教,拜谢。

springmvc视图解析器的prefix一定要配成全路径才能找到是为什么?

最近刚刚在尝试idea写代码,然后找了个配置尝试自己写,在进行jsp页面跳转的时候发现路径出了问题。 找了半天然后发现是视图解析器里面的prefix问题。 正确代码如下: ``` <!-- 配置视图解析器 显示ViewResolver --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/src/main/webapp/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> </bean> ``` 错误代码如下: ``` <!-- 配置视图解析器 显示ViewResolver --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> </bean> ``` 当我的prefix的路径写全的时候我才能进行页面跳转,而我按照错误代码写的时候就不能进行跳转页面报错404. 但是我在网上看了许多都是这样写的。。。然后搜了半天也没搜到和我类似的问题的。所以就在这里请教下各位大佬 pom.xml的配置如下 ``` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.liulin</groupId> <artifactId>test</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>test Maven Webapp</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <!-- 设置项目编码 --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <!-- spring版本号 --> <spring.version>4.3.5.RELEASE</spring.version> <!-- mybatis版本号 --> <mybatis.version>3.4.1</mybatis.version> <!-- log4j日志文件管理包版本 --> <slf4j.version>1.7.7</slf4j.version> <log4j.version>1.2.17</log4j.version> <!-- jackson包版本 --> <jackson.version>2.5.0</jackson.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <!--添加java ee依赖--> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> </dependency> <!-- 实现slf4j接口并整合 --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.2</version> </dependency> <!-- 添加JSON依赖 --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.7</version> </dependency> <!-- 添加mysql驱动依赖 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.41</version> <scope>runtime</scope> </dependency> <!-- 添加数据库连接池 --> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5.2</version> </dependency> <!-- 添加MyBatis依赖 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <!-- 添加mybatis/spring整合包依赖 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.3.1</version> </dependency> <!-- 添加Spring核心依赖 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency> <!--添加servlet依赖--> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> <!-- 添加JSTL标签类依赖 --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- 添加日志相关jar包 --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> </dependencies> <build> <finalName>test</finalName> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement> </build> </project> ``` 配置详细图: 1. ![图片说明](https://img-ask.csdn.net/upload/201907/16/1563262460_481220.png) 2. ![图片说明](https://img-ask.csdn.net/upload/201907/16/1563262471_776644.png) 3. ![图片说明](https://img-ask.csdn.net/upload/201907/16/1563262488_239707.png)

struts2返回freemarker显示FreeMarker template error!

<p>情况:action代码如下</p> <pre name="code" class="java">Map&lt;String,Object&gt;map=new HashMap&lt;String,Object&gt;(); map.put("deliveraddress", null); //获取导航数据 map.put("siteNavigationList", this.getCreateHeaderTemplate().findIndexSiteNavigation()); //获取商城基本数据 map.put("jshopbasicinfo", this.getCreateHeaderTemplate().findJshopbasicInfo()); //获取页脚分类数据 map.put("footcategory", this.getCreatefootertemplate().findFooterCateogyrT()); //获取页脚文章数据 map.put("footerarticle", this.getCreatefootertemplate().findFooterArticle()); //this.getCreateHeaderTemplate().getBasePath(map); fc.init("WEB-INF/theme/default/shop/deliveraddress.ftl", map); return Action.SUCCESS;</pre> <p> </p> <p>生成方法如下</p> <pre name="code" class="java">public void init(String ftl,Map&lt;String,Object&gt;data) throws TemplateException, IOException{ Configuration configuration=new Configuration(); configuration.setServletContextForTemplateLoading(ServletActionContext.getServletContext(), "/"); configuration.setEncoding(Locale.CHINA, "UTF-8"); Template template=configuration.getTemplate(ftl); template.setEncoding("UTF-8"); ActionContext ctx = ActionContext.getContext(); HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE); response.setContentType("text/html;charset="+template.getEncoding()); Writer out=response.getWriter(); template.process(data, out); }</pre> <p> </p> <p>struts.xml如下</p> <pre name="code" class="xml">&lt;action name="GetUserDeliverAddressForUserCenter" class="FrontDeliverAddressAction" method="GetUserDeliverAddressForUserCenter"&gt; &lt;!-- &lt;result name="success"&gt;/usercenter/businessmag/mydeliveraddress.jsp &lt;/result&gt; --&gt; &lt;result name="success" type="freemarker"&gt;WEB-INF/theme/default/shop/deliveraddress.ftl &lt;/result&gt; &lt;result name="input"&gt;/usercenter/login.jsp&lt;/result&gt; &lt;interceptor-ref name="defaultStack"&gt;&lt;/interceptor-ref&gt; &lt;/action&gt;</pre> <p> </p> <p>freemarker错误如下</p> <pre name="code" class="java">Expression jshopbasicinfo is undefined on line 8, column 15 in WEB-INF/theme/default/shop/deliveraddress.ftl. The problematic instruction: ---------- ==&gt; ${(jshopbasicinfo.jshopname)} [on line 8, column 12 in WEB-INF/theme/default/shop/deliveraddress.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression jshopbasicinfo is undefined on line 8, column 15 in WEB-INF/theme/default/shop/deliveraddress.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125) at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135) at freemarker.core.Dot._getAsTemplateModel(Dot.java:78) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.ParentheticalExpression._getAsTemplateModel(ParentheticalExpression.java:75) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:237) at org.apache.struts2.views.freemarker.FreemarkerResult.doExecute(FreemarkerResult.java:187) at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186) at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) at org.apache.struts2.json.JSONInterceptor.intercept(JSONInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.jshop.interceptor.impl.AuthorityLogininterceptor.doIntercept(AuthorityLogininterceptor.java:41) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619)</pre> <p> </p> <p>意思是说jshopbasicinfo没有定义,但是页面上已经显示出该有的数据了。但还是爆这个模板错误。我ftl中没有使用strtus2的标签,网上说如果使用了addactionerror这个方法可能报错,但是我没有使用啊。不知道怎么弄的。请教各位了~~~~</p>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

ArrayList源码分析(入门篇)

ArrayList源码分析 前言: 写这篇博客的主要原因是,在我上一次参加千牵科技Java实习生面试时,有被面试官问到ArrayList为什么查找的速度较快,插入和删除的速度较慢?当时我回答得不好,很大的一部分原因是因为我没有阅读过ArrayList源码,虽然最后收到Offer了,但我拒绝了,打算寒假学得再深入些再广泛些,下学期开学后再去投递其他更好的公司。为了更加深入理解ArrayList,也为

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

玩转springboot启动banner定义所得

最近接手了一个springboot项目,不是不熟悉这个框架,启动时打印的信息吸引了我。 这不是我熟悉的常用springboot的打印信息啊,我打开自己的项目: 还真是的,不用默认的感觉也挺高大上的。一时兴起,就去研究了一下源代码,还正是有些收获,稍后我会总结一下。正常情况下做为一个老程序员,是不会对这种小儿科感兴趣的,不就是一个控制台打印嘛。哈哈! 于是出于最初的好奇,研究了项目的源代码。看到

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

立即提问
相关内容推荐