- 黄标问题: “接口方法【】必须使用Javadoc注释”
解决方案:添加Javadoc形式的注释就好了 Java 支持三种注释方式。前两种分别是 // 和 /* /,第三种被称作说明注释,它以 /* 开始,以 */结束。Javadoc指的是第三种
- 如何让SpringMVC框架返回String类型的字符串。问题详情:我想让其返回200,但是发现出现404,200.jsp找不到。
解决方案:是因为springmvc会自动将view、modelandview、string解析成视图形式返回给前端。如果你要返回字符串需要在返回方法前面加上@ResponseBody注解
- HTTP Status 500 – Internal Server Error。然后看具体报错
Error creating bean with name 'loginController': Unsatisfied dependency expressed through field 'accountService'
A
我的是因为Service注解再serviceimpl导致的,添加在service修复了问题之前描述的不准确,这个错是因为这个bean无法创建导致的,看下applicationContext.xml(Spirng的核心配置)Springmvc.xml(MVC 的核心配置),web.xml(web应用的配置)。了解一下他们之间的关系,这个问题应该是Controller层归MVC扫还是Spring扫导致的
- http://localhost:8843/javaee_study_war_exploded 为什么什么我不叫后面那个访问不了,我先直接访问 / 为首页的
解决方案:有尝试几种方式,暂未解决 - 用postwoman发现访问不了localhost或者127.0.0.1
解决方案:查阅资料返现postwoman就是不行,不能访问本地,毕竟人家是在线的,她的localhost不是我的本地。后安装postman处理的
- Spring如何获取前端传递的参数
我们去是通过HttpServletRequest 对象获取
- 搭建的SSM框架无法访问controller
解决方案:检查是否是web.xml 和SpringMVC没有配置
我的web.xml配置
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<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>Archetype Created Web Application</display-name>
<!--配置前端控制器-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<!--默认匹配所有请求-->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--解决中文乱码的过滤器-->
<filter>
<filter-name>characterEncodingFilter</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>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
我的SpringMVC配置.因为我想用VUE做前端,前后端分离。索引静态资源用不上
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--开启注解扫描,只扫描Controller注解-->
<context:component-scan base-package="com.code">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!--配置的视图解析器对象-->
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!--过滤静态资源-->
<!--<mvc:resources location="/css" mapping="/css/**"/>
<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/js/" mapping="/js/**"/>-->
<!--开启SpringMVC注解的支持-->
<mvc:annotation-driven/>
</beans>
- vscode写vue发现缩进有问题。红线提示
原因:vue默认缩进2个空格,vscode默认缩进4个空格
解决方案:该vue配置或vscode配置(.editorconfig文件) 我选择改的vscode配置。点击右下角的空格就可以改了