spring mvc中使用@JsonView注解失效问题?

我在pojo中将属性标记上@JsonView 以希望在转化json时过滤掉某些属性。起先是没有问题。
后来因为需要设置日期格式转化问题,在sprin-mvc.xml配置文件中增加了如下设置

    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">    
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">    
                <property name="objectMapper">    
                    <bean class="com.fasterxml.jackson.databind.ObjectMapper">  
                        <!-- 处理responseBody 里面日期类型 -->    
                        <property name="dateFormat">    
                            <bean class="java.text.SimpleDateFormat">    
                                <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss" />    
                            </bean>    
                        </property>   
                    </bean>    
                </property>    
            </bean>    
        </mvc:message-converters>       
    </mvc:annotation-driven>

然后@JsonView注解的效果就没有了。劳驾问下大家这两个之间有什么关联,我应该怎么处理。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
对返回结果进行了统一封装,怎么使用@JsonView注解

``` @RequiresPermissions({"manager:view"}) @RequestMapping("/getManagers") @JsonView(Manager.simpleManager.class) public Result getManagers(){ Result result = new Result(); List<Manager> managers = managerService.selectList(null); if(managers!=null){ result.setCode(1); result.setData(managers); result.setMsg("查询成功"); } else { result.setCode(0); result.setMsg("查询失败"); } return result; } ``` 封装的返回 ``` public class Result { private String msg; private Integer code; private Object data; public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public Object getData() { return data; } public void setData(Object data) { this.data = data; } } ``` 只有把返回改成List<Manager>才有效,我这种情况应怎么处理?

spring mvc中使用post方式请求返回405

后台处理方法 ``` @RequestMapping(value="/doLogin", method=RequestMethod.POST) public ModelAndView doLogin(HttpSession session){ logger.info("user login."); session.setAttribute("USER", "admin"); //return "superMain.html"; return new ModelAndView(new InternalResourceView("/view/superMain.html")); } ``` mvc配置 ``` <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="order" value="1"/> <property name="contentNegotiationManager" ref="contentNegotiationManager"/> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/view/" /> </bean> </list> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/> </list> </property> </bean> ``` 页面html代码 ``` <form action="doLogin" method="post"> <div class="form-group"> <div class="input-group"> <div class="input-group-addon"><i class="fa fa-user"></i></div> <input class="form-control" placeholder="Username" type="text" /> </div> </div> <div class="form-group"> <div class="input-group"> <div class="input-group-addon"><i class="fa fa-asterisk"></i></div> <input class="form-control" placeholder="Password" type="password" /> </div> </div> <div class="row"> <div class="col-xs-4"> <div class="form-group text-right"> <button class="btn btn-success text-uppercase" type="submit">Sign In</button> </div> </div> </div> </form> ``` 错误信息 11:54:35.105 [http-apr-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'springMvc' processing POST request for [/cbos-web-1.0/doLogin] 11:54:35.118 [http-apr-8080-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /doLogin 11:54:35.133 [http-apr-8080-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public org.springframework.web.servlet.ModelAndView com.gtstar.cbos.web.controller.LoginController.doLogin(javax.servlet.http.HttpSession)] 11:54:35.137 [http-apr-8080-exec-3] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'loginController' - user login. 11:54:35.181 [http-apr-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.InternalResourceView: unnamed; URL [/view/superMain.html]] in DispatcherServlet with name 'springMvc' 11:54:35.183 [http-apr-8080-exec-3] DEBUG o.s.w.s.view.InternalResourceView - Forwarding to resource [/view/superMain.html] in InternalResourceView 'null' 11:54:35.183 [http-apr-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'springMvc' processing POST request for [/cbos-web-1.0/view/superMain.html] 11:54:35.189 [http-apr-8080-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /view/superMain.html 11:54:35.194 [http-apr-8080-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/view/superMain.html] 11:54:35.209 [http-apr-8080-exec-3] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Matching patterns for request [/view/superMain.html] are [/view/**] 11:54:35.226 [http-apr-8080-exec-3] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - URI Template variables for request [/view/superMain.html] are {} 11:54:35.238 [http-apr-8080-exec-3] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/view/superMain.html] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/WEB-INF/view/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@783c52dc]]] and 1 interceptor 11:54:35.245 [http-apr-8080-exec-3] DEBUG o.s.w.s.m.a.ResponseStatusExceptionResolver - Resolving exception from handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/WEB-INF/view/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@783c52dc]]]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported 11:54:35.250 [http-apr-8080-exec-3] DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/WEB-INF/view/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@783c52dc]]]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported 11:54:35.257 [http-apr-8080-exec-3] WARN o.s.web.servlet.PageNotFound - Request method 'POST' not supported 11:54:35.275 [http-apr-8080-exec-3] WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver - Handler execution resulted in exception: Request method 'POST' not supported 11:54:35.282 [http-apr-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'springMvc': assuming HandlerAdapter completed request handling 11:54:35.316 [http-apr-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request 11:54:35.317 [http-apr-8080-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request 望大师指导!!

请教关于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>

SpringMVC 配置@responsebody返回的只有父类属性,求解

SpringMVC 配置@responsebody返回json中的只有父类属性,求解使用的是springmvc 3.2.11,jackson2.1.5,springmvc的xml中没有任何直接相关Jackson的配置

springMVC controller中方法接收参数问题,怎么接收json对象

后台配置及代码 <!-- controller多请求配置即多个方法 请求解析器配置--> <bean id="paramMethodResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"> <property name="paramName" value="method"></property> </bean> <!-- 下边配置请求 --> <bean name="/busi/userInfo.action" class="com.mxci.busi.control.impl.UserInfoControllerImpl"> <property name="methodNameResolver"> <ref bean="paramMethodResolver"/><!-- 引用上边那个方法名称解析器 --> </property> </bean> public String regist(HttpServletRequest request, HttpServletResponse response, UserInfo userInfo) { // TODO Auto-generated method stub LOGGER.info("[CR]商户注册开始.请求商户信息:"+userInfo); MxciInsideResult mxciInsideResult = userInfoService.busiCustRegist(userInfo);//调用 //组装响应数据,并初始化进MxciResponseBody里面 MxciResponseServiceImpl mxciResponseService = new MxciResponseServiceImpl(mxciInsideResult.getRecode(),mxciInsideResult.getReData(),response); mxciResponseService.response();//响应结果到客户端 mxciResponseService=null;//置空 return null; } 目前请求地址这样写是可以封装层userId对象的 http://127.0.0.1:8090/mxciBusiness/busi/userInfo.action?method=regist&userId=wangyan&password=900613&certificateId=50022419901231739X&phoneNo=18696668026 请问怎么样修改才能用下边的地址访问能让后台接收到对象呢??? http://127.0.0.1:8090/mxciBusiness/busi/userInfo.action?method=regist&userInfo={"userId": "wangyan888","customerId": "BUSI20160125000001","lastErrorTime": null,"loginDate": null,"loginErrNum": 0,"password": "","phoneNo": "18696668026","reginDate": null,"status": 0,"valiDate":null}

Extbase无法识别自定义JsonView

<div class="post-text" itemprop="text"> <p>I am using typo3 7.6. I can't make extbase take my custom JsonView, it seems like it does not recognize it.</p> <p>I overwrite the default JsonView like this:</p> <pre><code>use TYPO3\CMS\Extbase\Mvc\View\JsonView as ExtbaseJsonView; class JsonView extends ExtbaseJsonView { /** * @var array */ protected $configuration = [ 'jobs' =&gt; [ '_exclude' =&gt; ['pid'], '_descend' =&gt; [ 'place' =&gt; [ '_only' =&gt; ['name'] ] ] ], ]; } </code></pre> <p>EDIT: According to this <a href="https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_7-6-2/typo3/sysext/extbase/Classes/Mvc/View/JsonView.php#L60-L157" rel="nofollow">docu</a> </p> <p>Now I don't understand why I still get this output as Json:</p> <pre><code>[{"description":"Owns products","pensum":100,"pid":55,"test":"Product","title":"Product Owner","uid":1}] </code></pre> <p>One the pid is still there even though it is in the exclude field and the place does not get outputed. It seems like extbase is ignoring my override, but I don't know why and no errors are ever thrown. I put my custom JsonView into Classes/View/JsonView.php</p> <p>My models are:</p> <p>Job</p> <pre><code>/** * Job */ class Job extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { /** * title * * @var string * @validate NotEmpty */ protected $title = ''; /** * description * * @var string */ protected $description = ''; /** * pensum * * @var int */ protected $pensum = 0; /** * test * * @var string */ protected $test = ''; /** * place * * @var \Vendor\SfpJobs\Domain\Model\Place */ protected $place = null; // below getter and setter } </code></pre> <p>Places</p> <pre><code>/** * Places */ class Place extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { /** * name * * @var string * @validate NotEmpty */ protected $name = ''; /** * numberOfEmployees * * @var int * @validate NotEmpty */ protected $numberOfEmployees = 0; /** * acquired * * @var \DateTime * @validate NotEmpty */ protected $acquired = null; // below getter and setter } </code></pre> <p>Controller</p> <pre><code>/** * JobAjaxController */ class JobAjaxController extends ActionController { /** * @var string */ protected $defaultViewObjectName = \TYPO3\CMS\Extbase\Mvc\View\JsonView::class; /** * jobRepository * * @var \Vendor\SfpJobs\Domain\Repository\JobRepository * @inject */ protected $jobRepository = NULL; /** * placeRepository * * @var \Vendor\SfpJobs\Domain\Repository\PlaceRepository * @inject */ protected $placeRepository = NULL; /** * action list * This function * * @param \Vendor\SfpJobs\Domain\Model\Job $job * @return void */ public function listAction() { $jobs = $this-&gt;jobRepository-&gt;findAll(); $this-&gt;view-&gt;assign('jobs', $jobs); $this-&gt;view-&gt;setVariablesToRender(array('jobs')); } } </code></pre> </div>

springboot用@RestController可以传递数据但是用@Controller却报错

利用RestController注解 ![图片说明](https://img-ask.csdn.net/upload/201805/11/1526051070_70419.png) ![图片说明](https://img-ask.csdn.net/upload/201805/11/1526051172_291303.png) 利用Controller ![图片说明](https://img-ask.csdn.net/upload/201805/11/1526051334_731815.png) ![图片说明](https://img-ask.csdn.net/upload/201805/11/1526051537_770817.png)

SpringMVC配置文件报错MappingJacksonJsonView

严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.view.json.MappingJacksonJsonView] for bean with name 'userListJson' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.json.MappingJacksonJsonView Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.view.json.MappingJacksonJsonView] for bean with name 'userListJson' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.json.MappingJacksonJsonView 代码: @RequestMapping(value = "/showUserListByJson") public String showUserListInJson(ModelMap mm) { List<Person> userList = new ArrayList<Person>(); Person user1 = new Person(); user1.setUsername("tom"); user1.setPassword("汤姆"); Person user2 = new Person(); user2.setUsername("john"); user2.setPassword("约翰"); userList.add(user1); userList.add(user2); mm.addAttribute("userList", userList); return "userListJson"; } <!-- XMl及JSON视图解析器配置 --> <bean id="userListJson" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" p:renderedAttributes="userList" />

页面直接显示了异步请求的json数据?

我在页面发送异步请求,后台对数据进行处理后返回json字符串,前台并没有进入到success或者error语句块,就直接显示了返回的json字符串。 异步请求: ``` jQuery.ajaxFileUpload({ secureuri:false, type : 'POST', url : 'web/contactsInfo/importExlSave', fileElementId : 'excelFile', dataType : 'json', data : { "projectId":${projectId} }, success : function(data) { if(data.state=='success') { toastr.success("人员导入完成!","系统消息"); $('#modal').modal('hide'); $('#tab').bootstrapTable('refresh', {url: 'web/contactsInfo/contactsInfoList?projectId=${projectId}'}); } else { toastr.error("人员导入出现异常!","系统消息"); } }, error : function(data) { toastr.error("系统发生异常!","系统消息"); } }); ``` 请求的处理方法 ``` public @ResponseBody Map<String,Object> importExlSave(MultipartFile excelFile,HttpServletRequest request,HttpServletResponse response){ String parameter = request.getParameter("projectId"); Map<String,Object> map = new HashMap<String,Object>(); map.put("state", "success"); map.put("message", "完成!"); return map; } ``` 关于将对象转成json字符串的配置 ``` <!-- 返回json格式配置开始 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- 解决Spring MVC返回json视图时,如何将对象直接序列化成不带变量名做为根节点的 json 报文 <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"> <property name="extractValueFromSingleKeyModel" value="true" /> </bean> --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list > <ref bean="mappingJacksonHttpMessageConverter" /> </list> </property> </bean> <!-- 返回json格式配置结束 --> ``` 大概就是这样。 我提交请求后得到的响应是这样的: ![图片说明](https://img-ask.csdn.net/upload/201702/28/1488266497_61268.png) 跪求大神帮助 如果觉得我给的不够详细,可以提出来,我补充

CakePHP - JsonView渲染是控制器的子功能

<div class="post-text" itemprop="text"> <p>I'm using Cakephp with <strong>json parse extension</strong> and the <strong>RequestHandler</strong> component in order to create Web services using json.</p> <p>I created a controller named <code>Ws</code> In this controller I have a named <code>userSubscribe</code></p> <p>In order to avoid a lot of <code>If else</code> statements in the next methods, I thought about using a private function inside this controller that will check somes conditions and stop the script normaly BUT ALSO render the json normaly. I just want to do a DRY way !</p> <p>My question is :</p> <p><strong>How could I render the json view in a sub function (called by the userSubscribe) ?</strong></p> <p>To make it clear, here is the style code that would like</p> <pre><code>public function userSubscribe() { $this-&gt;check(); // Following code only executed if check didn't render the json view // $data = ... $code = 1; $i = 2; } private function check() { $input = &amp;$this-&gt;request-&gt;data; if ($_SERVER["CONTENT_TYPE"] != "application/json") { // For example $result = "KO"; $this-&gt;set(compact("result")); $this-&gt;set('_serialize', 'result'); $this-&gt;render(); // HERE, it will stop the 'normal behaviour' and render the json with _serialize } if (!isset($input["input"])) { $result = "KO"; $this-&gt;set(compact("result")); $this-&gt;set('_serialize', 'result'); $this-&gt;render(); // HERE, it will stop the 'normal behaviour' and render the json with _serialize } } </code></pre> <p>It's seems to be quite simple to do, but why can't I find the answer ?!</p> <p>Thanks in advance for clue/advise/anything !</p> </div>

go用swagger生成的api文档中为什么只显示一个接口

我用go语言中的swagger生成的api文档为什么值只显示一个接口,是我写错了吗?还有下面画圈的地方,这个参数是什么意思啊 ![图片说明](https://img-ask.csdn.net/upload/201910/29/1572315242_440618.jpg)![图片说明](https://img-ask.csdn.net/upload/201910/29/1572315271_772973.jpg)

Jackson如何动态返回json?具体点:如何过滤类中成员属性(另一个对象)中的属性?

现在有: class ClassA { public interface ViewForSomeProperties {} @JsonView(ViewForSomeProperties.class) private int field;//基本类型 private ClassB b;//对象类型 //省略了getter、setter方法 } ClassB的定义假设为: class ClassB { private String field1; private String field2; //省略了getter、setter方法 } 问题:如何过滤掉ClassA 中 成员属性b 的某些属性(如field2)?即使返回ClassA的对象的json时,其成员属性b中只包含部分属性(field1)?

如何删除无用的JSP

<div class="post-text" itemprop="text"> <p>On the website that I'm developping, I'm using a lot of Ajax calls to display informations.</p> <p>Theses Ajax Call are as follow : </p> <pre><code>function deleteBookingAjax(rowId) { $.ajax({ url : "deleteRent.htm", type : "GET", data : { "rentId" : rowId }, dataType : 'json', cache : false, success : function(response) { if(response.error) { showPopupMessage(response.error, true); } }, statusCode : { 500 : function() { loggingMessage('Error 500'); reloadBookingTable(); }, 404 : function() { loggingMessage('Error 404'); reloadBookingTable(); } } }); } </code></pre> <p>To perform this call, I have also Controllers as follow :</p> <pre><code>@RequestMapping(value = "/deleteRent.htm") public String deleteRent(Long rentId, HttpServletRequest request, HttpServletResponse response) { if (rentId == null) { return null; } try { rentService.deleteRent(rentId); } catch (Exception e) { LOGGER.error(e); } response.setStatus(HttpStatus.SUCCESS); return ViewNames.BOOKINGS_PAGE; } </code></pre> <p>But my problem is that : to perform this Ajax call, I need to create a useless JSP file : <em>WEB-INF/jsp/deleteRent.jsp</em></p> <pre><code>&lt;%@page import="net.****.****.web.controllers.RentControllers"%&gt; &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt; &lt;%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt; </code></pre> <p>If I don't create theses files, the Ajax call is not working...</p> <p>When the file is not in the WEB-INF/ The Ajax call returns : </p> <pre><code>GET http://127.0.0.1/deleteRent.htm?rowId=1 404 (Not Found) </code></pre> <p>And the logs are showing : </p> <pre><code>2015-07-31 10:47:39,084 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Could not complete request javax.servlet.ServletException: File &amp;quot;/WEB-INF/jsp/deleteRent.jsp&amp;quot; not found at org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:417) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:384) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) .... </code></pre> <p>How can I make it work without theses files (I assume it will be in configurations... but where exactly and how ?), because it's not convinient to have a lot of JSP files but when only few of them have contents...</p> <p><strong>EDIT</strong> </p> <p>Here is the content of my context.xml, if the errror is located there, we never know : </p> <pre><code>&lt;!-- resources exclusions from servlet mapping --&gt; &lt;mvc:resources mapping="/css/**" location="/css/" /&gt; &lt;mvc:resources mapping="/images/**" location="/images/" /&gt; &lt;mvc:resources mapping="/scripts/**" location="/scripts/" /&gt; &lt;mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**" /&gt; &lt;!-- Enables the Spring MVC @Controller programming model --&gt; &lt;context:component-scan base-package="net.****.****.web" /&gt; &lt;context:annotation-config /&gt; &lt;mvc:annotation-driven /&gt; &lt;bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;classpath:/META-INF/messages_en.properties&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /&gt; &lt;!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/jsp directory --&gt; &lt;bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt; &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;property name="alwaysInclude" value="true" /&gt; &lt;property name="contentType" value="text/html; charset=UTF-8" /&gt; &lt;/bean&gt; &lt;bean id="annotationMethodHandlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /&gt; </code></pre> <p>Thanks in advance. :)</p> </div>

使用Joins在laravel视图中显示Json数据

<div class="post-text" itemprop="text"> <p>I'm trying to retrieve data from database to laravel blade view with join associate table.</p> <p>in my case I have two tables called <code>interesting_courses</code> and <code>courses</code>. here some student can have many interesting courses. Therefore <code>courses_id</code> stored as <code>json array</code> in database as follows.</p> <pre><code>["1","11","15","16"] </code></pre> <p>but I need to join the courses table to get the associate course name as follows.</p> <pre><code>["Hospitality","Business Management","Auto Mobile","Health Care"] </code></pre> <p>Below is my controller</p> <pre><code>$intresting_courses = DB::table('intresting_courses') -&gt;join('courses','courses.id','=','intresting_courses.courses_id') -&gt;where('intresting_courses.youth_id',$id) -&gt;first(); </code></pre> <p>How can I join the tables.</p> </div>

springmvc sessionFactory is null

严重: Servlet.service() for servlet [spring2] in context with path [/Lbl] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException 说明:@resource和@annotional都不起作用。 网上的方法都试过了,不起作用 spring2-servlet.xml <?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm" 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/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <context:component-scan base-package="com.lbl.active" /> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/> <bean id="bookXmlView" class="org.springframework.web.servlet.view.xml.MarshallingView"> <constructor-arg> <bean class="org.springframework.oxm.xstream.XStreamMarshaller"> <property name="autodetectAnnotations" value="true"/> </bean> </constructor-arg> </bean> <bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"> </bean> </beans> application.xml <context:annotation-config/> <!-- 自动扫描与装配 --> <context:component-scan base-package="com.lbl"></context:component-scan> <!-- 导入外部的properties--> <context:property-placeholder location="classpath:jdbc.properties"/> <!--配置session工厂 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 配置数据库路径 classpath:WEB-INF\classes\hibernate.cfg.xml--> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> <!-- 配置数据库c3p0连接池 dataSource写错导致bean创建异常错误信息属性值设置错误 --> <property name="dataSource" > <!-- dataSouce应该写成dataSource第三个错误 --> <bean class="com.mchange.v2.c3p0.ComboPooledDataSource"> <!-- 配置数据库信息 --> <property name="jdbcUrl" value="${jdbcUrl}"></property> <property name="driverClass" value="${driverClass}"></property> <property name="user" value="${user}"></property> <property name="password" value="${password}"></property> <!-- 其他配置 --> </bean> </property> </bean> <!-- 配置声明事物管理 采用注解方式--> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" > <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:annotation-driven transaction-manager="txManager"/> </beans> web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>Lbl</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>encodingFilter</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>encodingFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter> <filter-name>openSession</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> <init-param> <param-name>sessionFactoryBeanName</param-name> <param-value>sessionFactory</param-value> </init-param> </filter> <filter-mapping> <filter-name>openSession</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>spring2</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring2</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> 出错的类 @Transactional public class DaoService<T> implements DaoLbl<T>{ @Resource private SessionFactory sessionFactory; private Class<T> clazz; @SuppressWarnings("unchecked") public DaoService(){ System.out.println("---1---->>>:"+this.getClass()); // System.out.println("----2--->>>:"+this.getClass().getGenericSuperclass()); //使用反射技术获得 T的真实类型 ParameterizedType pt=(ParameterizedType)this.getClass()// .getGenericSuperclass();//获取当前new的泛型父类类型 System.out.println("------->:"); this.clazz=(Class<T>)pt.getActualTypeArguments()[0]; //获取第一个参数的实际类型 System.out.println("class--->" + clazz); } protected Session getSession(){ // // String path="C:/Users/admin/workspace/Lbl/WebContent/WEB-INF/applicationContext.xml"; // ApplicationContext ac=new FileSystemXmlApplicationContext(path); // SessionFactory sessionFactory=(SessionFactory)ac.getBean("sessionFactory"); // System.out.println("00001113333333----000->"+ sessionFactory); // System.out.println("00001113333333----000->"+ sessionFactory.openSession()); // return sessionFactory.openSession(); // System.out.println("0000000->"+ sessionFactory.getCurrentSession()); try { return sessionFactory.getCurrentSession(); } catch (Exception e) { e.getStackTrace(); } return null; } }

关于EXT用json返回结果分页的问题

最近在用ext,可遇到了一个很奇怪的问题 index.jsp <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib prefix="s" uri="/struts-tags" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href=" <%=basePath%>"> <title>My JSP 'index.jsp' starting page </title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" /> <script type="text/javascript" src="js/ext-base.js"> </script> <script type="text/javascript" src="js/ext-all-debug.js"> </script> <script type="text/javascript" src="js/ext-lang-zh_CN.js"> </script> <script> function renderSex(value) { if (value == 'male') { return " <span style='color:red;font-weight:bold;'>红男 </span> <img src='user_male.png' />"; } else { return " <span style='color:green;font-weight:bold;'>绿女 </span> <img src='user_female.png' />"; } } function renderDescn(value, cellmeta, record, rowIndex, columnIndex, store) { var str = " <input type='button' value='查看详细信息' onclick='alert(\"" + "这个单元格的值是:" + value + "\\n" + "这个单元格的配置是:{cellId:" + cellmeta.cellId + ",id:" + cellmeta.id + ",css:" + cellmeta.css + "}\\n" + "这个单元格对应行的record是:" + record + ",一行的数据都在里边\\n" + "这是第" + rowIndex + "行\\n" + "这是第" + columnIndex + "列\\n" + "这个表格对应的Ext.data.Store在这里:" + store + ",随便用吧。" + "\")'>"; return str; } Ext.onReady(function(){ var sm = new Ext.grid.CheckboxSelectionModel(); var cm = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), sm, {header:'编号',dataIndex:'id',sortable:true}, {header:'性别',dataIndex:'sex',sortable:true,renderer:renderSex}, {header:'名称',dataIndex:'name',sortable:true}, {header:'描述',dataIndex:'descn',sortable:true,renderer:renderDescn} ]); var ds = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({url:'gird.jsp'}), reader: new Ext.data.JsonReader({ totalProperty: 'totalProperty', root: 'root' },[ {name: 'id',mapping:0}, {name: 'sex',mapping:1}, {name: 'name',mapping:2}, {name: 'descn',mapping:3} ]) }); var grid = new Ext.grid.GridPanel({ renderTo: 'grid', height:500, ds: ds, cm: cm, sm: sm, bbar: new Ext.PagingToolbar({ pageSize: 2, store: ds, displayInfo: true, displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条', emptyMsg: "没有记录" }) }); ds.load({params:{start:0,limit:2}}); grid.render(); }); </script> </head> <body> <div id="grid" style="height:265px;"> </div> <br> </body> </html> gird.jsp <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href=" <%=basePath%>"> <title>My JSP 'gird.jsp' starting page </title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% String start = request.getParameter("start"); String limit = request.getParameter("limit"); System.out.println("start=" + start); System.out.println("limit=" + limit); try { int index = Integer.parseInt(start); int pageSize = Integer.parseInt(limit); String json = "{totalProperty:100,root:["; for (int i = index; i < pageSize + index; i++) { json += "{id:" + i + ",sex:'sex" + i + "',name:'name" + i + "',descn:'descn" + i + "'}"; if (i != pageSize + index - 1) { json += ","; } } json += "]}"; System.out.println("json===" + json); response.getWriter().write(json); response.getWriter().close(); } catch(Exception ex) { } %> </body> </html> 刷新index.jsp打印出来 start=0 limit=2 json==={totalProperty:100,root:[{id:0,sex:'sex0',name:'name0',descn:'descn0'},{id:1,sex:'sex1',name:'name1',descn:'descn1'}]} 点分页的下一页打印出 start=2 limit=2 json==={totalProperty:100,root:[{id:2,sex:'sex2',name:'name2',descn:'descn2'},{id:3,sex:'sex3',name:'name3',descn:'descn3'}]} 可页面gird里就是没有数据,分页有效 gird.jsp里的json是出来了,但index.jsp里的ext接收不到数据,表格里就是没数据显示,但表格也只显示2列,就是没实际的数据结果 这是为什么?

使用Cakephp渲染JSON

<div class="post-text" itemprop="text"> <p>I'm trying to return a Json object from an outside form with Cakephp 2.1. I have all my data, and I've looked at the responses, and the problem is I get a massive error text before my JSON!</p> <p>Heres the code I use to print the json:</p> <pre><code>if (!$validationPassed) { if ($ExternalRequest) { if ($shouldEchoErrors){ Configure::write('debug',0); // Disabled so theoretically it can't even print errors $this-&gt;RequestHandler-&gt;setContent('json', 'application/json' ); $json = json_encode($this-&gt;Customer-&gt;validationErrors); echo $json; $this-&gt;autoRender = false ; } </code></pre> <p>The JSON it prints is correct, <code>{"Email":["EmailUnique"]}</code>. However I get a huge preformatted error message before that, stack trace and everything. </p> </div>

使用 PHP 美化打印 JSON

<div class="post-text" itemprop="text"> <p>I'm building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using <code>json_encode</code>. Here is an example script:</p> <pre><code>$data = array('a' =&gt; 'apple', 'b' =&gt; 'banana', 'c' =&gt; 'catnip'); header('Content-type: text/javascript'); echo json_encode($data); </code></pre> <p>The above code yields the following output:</p> <pre><code>{"a":"apple","b":"banana","c":"catnip"} </code></pre> <p>This is great if you have a small amount of data, but I'd prefer something along these lines: </p> <pre><code>{ "a": "apple", "b": "banana", "c": "catnip" } </code></pre> <p>Is there a way to do this in PHP without an ugly hack? It seems like someone at <a href="https://graph.facebook.com/19292868552" rel="noreferrer">Facebook</a> figured it out.</p> </div> <p>转载于:https://stackoverflow.com/questions/6054033/pretty-printing-json-with-php</p>

ssm返回JSON数据提示 无法写入JSON

![图片说明](https://img-ask.csdn.net/upload/201704/14/1492151584_701660.png) ![图片说明](https://img-ask.csdn.net/upload/201704/14/1492151594_887916.png) ![图片说明](https://img-ask.csdn.net/upload/201704/14/1492151602_257605.png) 这是我的配置,在线等 急急急

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

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

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

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

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

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

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

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

和黑客斗争的 6 天!

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

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

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

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、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 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多个条件是什么逻辑关系?条件判断在什么时候执...

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

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

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

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

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

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

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

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

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

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

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

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

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐