ssm或者ssh项目,启动访问路径设置总结(直接访问contorller层)微信测试

1.先访问jsp文件,在从jsp访问contorller层
第一步:
访问jsp给mvc中配置默认视图
添加如下:

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
    <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->  
    <property name="prefix" value="/WEB-INF/jsp/" />  
    <property name="suffix" value=".jsp" />  
</bean>  

第二步:
在web.xml中添加如下

<servlet-mapping>  
        <servlet-name>SpringMVC</servlet-name>  
        <url-pattern>/</url-pattern>
    </servlet-mapping>  
    <welcome-file-list>
       <welcome-file>xxxx/xxxx/xxxx.jsp</welcome-file>
    </welcome-file-list>

第三步:
在jsp中自己编译跳转路径

2.直接访问contorller层,在跳转jsp页面
方法1:在controller类和该类方法上注解路径(“/”)

@Controller
@RequestMapping("/")
public class index {
  @RequestMapping(value = "/", method = RequestMethod.GET)
  public String index(Model model){
    return "index";
  }
}

web.xml文件配置

<welcome-file-list>
   <welcome-file></welcome-file>
</welcome-file-list>

方法2
controller类照常配置
配置web.xml时把下方内容删除

 <!--<welcome-file-list>-->
        <!--&lt;!&ndash;<welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>&ndash;&gt;-->
        <!--<welcome-file>/user/weChat</welcome-file>-->
    <!--</welcome-file-list>-->

方法3
在mvc配置文件中配置

<!-- 定义无Controller的path<->view直接映射 -->
<mvc:view-controller path="/" view-name="redirect:login" />

在web.xml配置文件中配置

<welcome-file-list>
   <welcome-file>login</welcome-file>
</welcome-file-list>

如果进行微信测试用此框架,启动项目后 打开网站报404 属于正常,正常使用微信接口就行

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值